Beispiel #1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(generateAtRuntime);

        indexClass = EditorGUILayout.Popup(indexClass, confignames.ToArray());
        MenuGenerator generator = (MenuGenerator)target;

        EditorGUILayout.PropertyField(hastheme);
        if (((MenuGenerator)target).hastheme)
        {
            Type           t        = ((MenuGenerator)target).configurationschema.GetType();
            PropertyInfo[] proplist = t.GetProperties();
            Propertynames = new List <string>();
            for (int i = 0; i < proplist.Length; i++)
            {
                Propertynames.Add(proplist[i].Name);
                if (proplist[i].Name == themepropertyname.stringValue)
                {
                    indexParameter = i;
                }
            }
            indexParameter = EditorGUILayout.Popup(indexParameter, Propertynames.ToArray());
            EditorGUILayout.PropertyField(allowOnlyCompleteThemes);
            ThemeManager.StartUp();
        }
        else
        {
            ((MenuGenerator)target).ThemePropertyName = "";
        }

        string message = ((MenuGenerator)target).generateAtRuntime ? "Check the result" : "Create the menu";

        if (GUILayout.Button(message))
        {
            ((MenuGenerator)target).configurationname = confignames.ElementAt(indexClass);
            if (Propertynames.Count > 0)
            {
                ((MenuGenerator)target).ThemePropertyName = Propertynames.ElementAt(indexParameter);
            }
            generator.generateMenu();
            if (!((MenuGenerator)target).generateAtRuntime)
            {
                generateEvents((MenuGenerator)target);
            }
        }

        serializedObject.ApplyModifiedProperties();
    }