Esempio n. 1
0
        private static void OpenECSInspector()
        {
            ECS_Inspector inspector = EditorWindow.GetWindow <ECS_Inspector>();

            inspector.titleContent.image = EditorGUIUtility.IconContent("Grid.BoxTool").image;
            inspector.titleContent.text  = "ECS Inspector";
            inspector.Show();
        }
        protected override void OnInspectorDefaultGUI()
        {
            base.OnInspectorDefaultGUI();

            GUILayout.BeginHorizontal();
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("Open In Inspector", EditorGlobalTools.Styles.ButtonLeft))
            {
                ECS_Inspector inspector = EditorWindow.GetWindow <ECS_Inspector>();
                inspector.titleContent.text = "ECS Inspector";
                inspector.Entity            = Target;
                inspector.Show();
            }
            Button(GenerateID, "Generate ID", EditorGlobalTools.Styles.ButtonRight);
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUI.backgroundColor = Color.cyan;
            if (GUILayout.Button("Show Component", EditorGlobalTools.Styles.ButtonLeft))
            {
                ECS_Component[] components = Target.GetComponents <ECS_Component>();
                for (int i = 0; i < components.Length; i++)
                {
                    components[i].hideFlags = HideFlags.None;
                }
                HasChanged();
            }
            if (GUILayout.Button("Hide Component", EditorGlobalTools.Styles.ButtonRight))
            {
                ECS_Component[] components = Target.GetComponents <ECS_Component>();
                for (int i = 0; i < components.Length; i++)
                {
                    components[i].hideFlags = HideFlags.HideInInspector;
                }
                HasChanged();
            }
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            PropertyField("_name", "Name");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            PropertyField("_id", "ID");
            GUILayout.EndHorizontal();
        }