ResourcePathA tool to pick a resource path (a string) with:
- required types or interfaces
- display a type instead of showing a string
- pick a suitable object using a custom picker
Parameters:
-
EStr eStr = EStr.Resource: which kind of string value you expected:Resource: a resource pathAssetDatabase: an asset path. You should NOT use this unless you know what you are doing.Guid: the GUID of the target object. You should NOT use this unless you know what you are doing.
-
bool freeSign=false:trueto allow to assign any object, and gives a message if the signed value does not match.falseto only allow to assign matched object, and trying to prevent the change if it's illegal. -
bool customPicker=true: use a custom object pick that only display objects which meet the requirements -
Type compType: the type of the component. It can be a component, or an object likeGameObject,Sprite. The field will be this type. It can NOT be an interface -
params Type[] requiredTypes: a list of required components or interfaces you want. Only objects with all the types can be signed. -
AllowMultiple: No
Known Issue: IMGUI, manually assign a null object by using Unity's default pick will assign an empty string instead of null. Use custom pick to avoid this inconsistency.
using SaintsField; // resource: display as a MonoScript, requires a BoxCollider [ResourcePath(typeof(Dummy), typeof(BoxCollider))] [InfoBox(nameof(myResource), true)] public string myResource; // AssetDatabase path [Space] [ResourcePath(EStr.AssetDatabase, typeof(Dummy), typeof(BoxCollider))] [InfoBox(nameof(myAssetPath), true)] public string myAssetPath; // GUID [Space] [ResourcePath(EStr.Guid, typeof(Dummy), typeof(BoxCollider))] [InfoBox(nameof(myGuid), true)] public string myGuid; // prefab resource [ResourcePath(typeof(GameObject))] [InfoBox(nameof(resourceNoRequire), true)] public string resourceNoRequire; // requires to have a Dummy script attached, and has interface IMyInterface [ResourcePath(typeof(Dummy), typeof(IMyInterface))] [InfoBox(nameof(myInterface), true)] public string myInterface;
