Coder Social home page Coder Social logo

fracturalcsharpresourceregistry's Introduction

Arhive Notice โš ๏ธ

This repository has been archived since resource registering functionality has been moved directly into FracturalCommons.

FracturalCSharpResourceRegistry

Deploy Unit Tests

This is a Godot C# plugin that registers custom C# resources and custom nodes for Godot. This plugin serves as a workaround for the Godot engine's C# resource missing in context menu issue.

Based off of CustomResourceRegisterPlugin made by wmigor

How to Use

Adding custom C# resources/nodes:

  1. Add the RegisteredTypeAttribute to your resource/node class. The file containing your class must have the same name as the class in order to be detected by the plugin. Make sure to add using MonoCustomResourceRegistry; to the top of your file to import this plugin's namespace, which contains RegisteredTypeAttribute.
  2. Make sure your C# file is under one of the Resource Script Directories
  3. Rebuild the solution
  4. Press the "CRR" button to update the registered types

Deleting custom C# resources/nodes:

  1. Delete the C# resource/node script
  2. Rebuild the solution
  3. Press the "CRR" button to update the registered types

Anytime the Plugin registers/unregisters a resource/node, the plugin will print its actions into the Output window.

RegisteredTypeAttribute

[RegisteredType(string name, string iconPath = "", string baseType = ""))]
  • name - Name of the custom type.
  • iconPath (Optional) - File path to the icon displayed for the custom type. Leave empty for no custom icon.
  • baseType (Optional) - Name of the base type. Leave empty for the default base type ("Node" for custom nodes and "Resource" for custom resources).

Sample usage:

// Inside a file named CustomNodeDemo.cs
using MonoCustomResourceRegistry;

// Registers a custom type with 
// 	a name of "CustomNodeDemo",
//	an icon located at "res://custom_icon.png",
//	and a base type of "Node2D"
[RegisteredType(nameof(CustomNodeDemo), "res://custom_icon.png", nameof(Node2D))]
public class CustomNodeDemo : Node2D
{
	...
}
// Inside a file named CustomNodeDemo2.cs
using MonoCustomResourceRegistry;

// Registers a custom type with 
// 	a name of "CustomNodeDemo",
//	no icon,
//	and a base type of "Button"
[RegisteredType(nameof(CustomNodeDemo), "", nameof(Button))]
public class CustomNodeDemo2 : Button
{
	...
}
// Inside a file named CustomNodeDemo3.cs
using MonoCustomResourceRegistry;

// Registers a custom type with 
// 	a name of "CustomNodeDemo",
//	no icon,
//	and a default base type of "Resource"
[RegisteredType(nameof(CustomNodeDemo))]
public class CustomNodeDemo3 : Resource
{
	...
}

Settings

This plugin comes with some settings to configure how C# resources are loaded. The settings can be accessed by going to Project > ProjectSettings > General > Mono Custom Resource Registry.

All settings are listed below:

Class Prefix - The prefix that is seen before all custom nodes and resources.

Resource Script Directories - The paths to the directories where you want to scan for C# resource scripts to register as custom resources. By default, it only contains "res://".

Search Type - The method used to gather custom C# resource scripts.

  • Namespace - Looks for scripts by using their namespace as a directory.

    For example with the C# script below, the plugin will look under each resource script directory for the script by using the path "./Some/Long/Namespace/Something.cs".

     namespace Some.Long.Namespace
     {
     	public class Something : Resource
     	{
     	}
     }
  • Recursive - Looks for scripts by searching through all "Resource Script Directories" and the directories within them.

fracturalcsharpresourceregistry's People

Contributors

atlinx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.