Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        SelectObjectsScriptFunction sosf = (SelectObjectsScriptFunction)target;  //points to this SelectObjectsScriptFunction

        populateScriptDroplist(sosf);
        populateMethodDroplist(sosf);
    }
Ejemplo n.º 2
0
 void Start()
 {
     dropdown = GetComponent <Dropdown>();
     selectObjectsScriptFunction = GetComponent <SelectObjectsScriptFunction>();
     dropdown.onValueChanged.AddListener(delegate {
         MonoBehaviour monoBehaviour = selectObjectsScriptFunction.SelectedScript();
         MethodInfo method           = selectObjectsScriptFunction.SelectedMethod();
         method.Invoke(monoBehaviour, new object[] { dropdown.value });
     });
 }
Ejemplo n.º 3
0
    void populateMethodDroplist(SelectObjectsScriptFunction sosf)
    {
        List <string> methodNames     = new List <string>();
        GUIContent    methodListLabel = new GUIContent("Methods");
        MonoBehaviour selectedScript  = sosf.attachedScripts[sosf.scriptIdx];

        sosf.scriptMethods = (MethodInfo[])Util.GetScriptMethods(selectedScript);
        foreach (MethodInfo methodInfo in sosf.scriptMethods)
        {
            methodNames.Add(methodInfo.Name);
        }
        sosf.methodIdx = EditorGUILayout.Popup(methodListLabel, sosf.methodIdx, methodNames.ToArray());
    }
Ejemplo n.º 4
0
    void populateScriptDroplist(SelectObjectsScriptFunction sosf)
    {
        List <string> attachedScriptNames = new List <string>();
        GUIContent    scriptListLabel     = new GUIContent("Scripts");

        sosf.attachedScripts = (MonoBehaviour[])sosf.gameObject.GetComponents <MonoBehaviour>();
        foreach (MonoBehaviour monoBehaviour in sosf.attachedScripts)
        {
            attachedScriptNames.Add(monoBehaviour.GetType().Name);
        }

        sosf.scriptIdx = EditorGUILayout.Popup(scriptListLabel, sosf.scriptIdx, attachedScriptNames.ToArray());
    }