Skip to content
chaolun edited this page Aug 14, 2019 · 2 revisions

EasyContextMenu

  • QuickStart

    • Get all the Static methods that have ContextMenu attribute when [InitializeOnLoadMethod] called

    • Get all the UnityEngine.Object methods that have ContextMenu attribute when OnEnable() called

    • Add these methods to a special list, and then other classes that inherit the EasyContextMenu can easily call these methods

  • ContextMenu Buttons

    Quickly add buttons for utility functions to the inspector by using UnityEngine. ContextMenuAttribute

    public class ContextMenuTest : MonoBehaviour
    {
        public bool isTestEnabled;
    
        [ContextMenu("Test Function")]
        private void MyTestFunction()
        {
            Debug.Log("Test function fired");
        }
    
        [ContextMenu("Test Function", isValidateFunction:true)]
        private bool TestFunctionValidate()
        {
            return isTestEnabled;
        }
    
        [ContextMenu("Other Test")]
        private void NonValidatedTest()
        {
            Debug.Log("Non validated test fired");
        }
    }
    

ScriptableObject Window

  • Right click in Project Window and Select Create -> Custom Script -> ScriptableObject Window

  • You can use search or drop-down menu select a ScriptableObject (you can found all ScriptableObject in project)

  • Click Create Button create you selected class as a .asset file

Template Script Window

  • Right click in Project Window and Select Create -> Custom Script -> Template Script Window

  • You can use search or drop-down menu select a IScriptAssetInstaller (you can found all IScriptAssetInstaller in project)

  • Click Create Button create you selected template script as a .cs file

Hierarchy Context Menu

The ContextMenu functions you want to called must are Static. You can set the split line by setting the priority value (split line every 50 values). You even can call a method with a parameter and the parameter type must be set as System.Object. The enter parameter is you current selected Object

[ContextMenu ("GameObject/Do Something/NonParam", false, 1)]
static public void DoSomething () { ... }

[ContextMenu ("GameObject/Do Something/NonParam", true, 1)]
static public bool CheckDoSomething () { ... return true; }

[ContextMenu ("GameObject/Do Something/Param", false, 2)]
static public void DoSomething (object activeGameObject) { ... }

Search Missing Components

The components on the gameObject are missing? This is a very common situation, because programmers need to modified components and can't remember all gameObjects added these components

But we don't want to missing components of the gameObjects exists in the scene. Of course we can code a simple script to remove all missing components. But it's not intuitive, maybe we need know where missing component and use a new component to replace it

Fortunately, UniEasy achieved this feature. You can right click in Hierarchy Window and select UniEasy -> Search for All Missing Components Then click ...

Now all gameObjects that missing components are listed in the Hierarchy Window

BatchProcessingWindow

Click the Window -> Batch Processing Window button on the menu bar to Open the Batch Processing Window

It can do the following:

  • Order gameObjects and format gameObjects name in Hierarchy

  • Manage render queue of materials in Hierarchy

  • Batch replace gameObjects with prefab

  • Categorize referenced assets

  • Check whether assets be used in somewhere or by something

EnumMaskDrawer

You can use EnumMaskAttribute to draw a field for enum masks, eg

public enum LoadingScreenLayer
{
    Default,
    Overlay,
}

public class Example : MonoBehaviour
{
    [EnumMask]
    public LoadingScreenLayer LoadingMask = (LoadingScreenLayer)(1 << 0);
}

TypePopupDrawer

You can use TypePopupAttribute to draw a type popup selection field, eg

public class Example : MonoBehaviour
{
    [TypePopup(typeof(AnimatorEvent))]
    public string EventType;
}

Clone this wiki locally