コード例 #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        myScript = (GUIGenerator)target;

        GUILayout.BeginHorizontal();

        selected = EditorGUILayout.Popup("Main Screen", selected, options.ToArray());

        if (GUILayout.Button("Update Hierarchy", EditorStyles.miniButtonRight)) {
            HierarchyChanged();
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(20);

        if (GUILayout.Button("Generate Files"))
        {
            List<string> files = myScript.ExistingFiles();

            if(files.Count > 0){
                string str = "Files in conflict:";
                for(int i = 0 ; i < files.Count ; ++i){
                    str += "\n  - " + files[i];
                }
                str += "\n\nDo you wish to proceed?";

                if(EditorUtility.DisplayDialog("Files in Conflict", str, "Yes", "No")){
                    Debug.Log("YES");

                    myScript.activeScreen = selected;

                    GenerateFiles();
                }
                else{
                    Debug.Log("NO");
                }
            }
            else{
                GenerateFiles();
            }
        }
    }
コード例 #2
0
    //void OnDisable() {
    //    //Debug.Log("OnDisable");
    //    EditorApplication.hierarchyWindowChanged -= HierarchyChanged;
    //}
    private static void HierarchyChanged()
    {
        //Debug.Log("HierarchyChanged! " + options.Count + " - " + selected);

        if (options.Count > selected) {
            string oldValue = options[selected];

            myScript = (GUIGenerator)instance.target;
            options = myScript.GetMainPanels();

            if (options[selected] != oldValue) {
                for (int i = 0; i < options.Count; ++i) {
                    if (options[i] == oldValue) {
                        selected = i;
                        break;
                    }
                }
            }
        }
        else {
            options = myScript.GetMainPanels();
        }
    }