예제 #1
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window         = (UnitAIEditorWindow)EditorWindow.GetWindow(typeof(UnitAIEditorWindow), false, "AI Unit Editor");
            window.minSize = new Vector2(400, 300);
            //~ window.maxSize=new Vector2(375, 800);

            LoadDB();

            InitLabel();

            window.SetupCallback();

            window.OnSelectionChange();
        }
예제 #2
0
        private SerializedObject srlObj; //serialized obj (of the selected units)

        #endregion Fields

        #region Methods

        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (UnitAIEditorWindow)EditorWindow.GetWindow(typeof (UnitAIEditorWindow), false, "AI Unit Editor");
            window.minSize=new Vector2(400, 300);
            //~ window.maxSize=new Vector2(375, 800);

            LoadDB();

            InitLabel();

            window.SetupCallback();

            window.OnSelectionChange();
        }
예제 #3
0
 static void OpenAIUnitEditor()
 {
     UnitAIEditorWindow.Init();
 }
예제 #4
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake();
            }

            GUI.changed = false;

            serializedObject.Update();

            EditorGUILayout.Space();


            //EditorGUILayout.HelpBox("Editing UnitAI component using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info);
            if (GUILayout.Button("Unit Editor Window"))
            {
                UnitAIEditorWindow.Init();
            }


            if (TDSEditor.IsPrefab(instance.gameObject))
            {
                if (!TDSEditor.ExistInDB(instance))
                {
                    EditorGUILayout.Space();

                    EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible by other editor.", MessageType.Warning);
                    GUI.color = new Color(1f, 0.7f, .2f, 1f);
                    if (GUILayout.Button("Add Prefab to Database"))
                    {
                        UnitAIEditorWindow.Init();
                        UnitAIEditorWindow.NewItem(instance);
                        UnitAIEditorWindow.Init();                                      //call again to select the instance in editor window
                    }
                    GUI.color = Color.white;
                }

                EditorGUILayout.Space();
            }


            EditorGUILayout.Space();



            cont = new GUIContent("Unit Name:", "The unit name to be displayed in game");
            PropertyFieldL(serializedObject.FindProperty("unitName"), cont);

            DrawFullEditor();

            EditorGUILayout.Space();

            DefaultInspector();

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }