예제 #1
0
        static public void ShowEditor()
        {
            if (Selection.activeGameObject != null)
            {
                var poolConfig = Selection.activeGameObject.GetComponent <EntityPoolConfig> ();

                ZEditorWindow editor = EditorWindow.GetWindow <ZEditorWindow>("Pool Config");
                editor.curPoolConfig = poolConfig;


                if (editor.curPoolConfig != null)
                {
                    editor.WndName = editor.curPoolConfig.gameObject.name;
                    editor.loadLayout();
                }

                editor.OnSelWindow += (wndID) => {
                    //Debug.Log("OnSelWindow" + wndID);

                    if (wndID >= 0)
                    {
                        editor.curPoolConfig.SelAEntity(wndID);

                        editor.strTempEditEntityName = editor.curPoolConfig.CurEntity.Name;

                        EditorApplication.RepaintHierarchyWindow();

                        if (EntityPoolInspectorEditor.curEditor != null)
                        {
                            EntityPoolInspectorEditor.curEditor.Repaint();
                        }
                    }
                    else
                    {
                        editor.strTempEditEntityName = "No Selected";
                    }
                };

                Selection.selectionChanged += () => editor.RefreshAndRepaint();

                editor.OnLinkNode += (parentID, subID) => {
                    //Debug.Log("OnLinkNode " + parentID + " sub " + subID);
                    editor.curPoolConfig.PoolNodeRoot.SetRelation(parentID, subID);
                    EntityPoolEditorBuildUtils.SaveEntityPoolConfigData(editor.curPoolConfig.PoolNodeRoot);
                    editor.Refresh();
                };
            }
        }
예제 #2
0
        //在这里方法中就可以绘制面板。
        public override void OnInspectorGUI()
        {
            curEntity = poolConfig.CurEntity;

            serializedObject.Update();
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Edit"))
            {
                ZEditorWindow.ShowEditor();
            }

            var oldColor = GUI.color;

            GUI.color = Color.yellow;
            EditorGUILayout.LabelField("Entity x " + poolConfig.CurPool.TemplateCount);

            GUILayout.FlexibleSpace();

            GUI.color = oldColor;


            if (GUILayout.Button("Reload"))
            {
                Reload();
            }

            EditorGUILayout.EndHorizontal();

            if (curEntity != null)
            {
                DrawEntity();
            }
            else
            {
                EditorGUILayout.LabelField("please select a entity");
            }

            //serializedObject.Update();
            serializedObject.SetIsDifferentCacheDirty();
            EditorApplication.DirtyHierarchyWindowSorting();
            serializedObject.ApplyModifiedProperties();
        }