コード例 #1
0
        /// <inheritdoc />
        public override void OnInspectorGUI()
        {
            if (!CustomEditorStyles.IsCustomStyleLoaded())
            {
                return;
            }
            serializedObject.Update();

            // Draw Identity settings
            _drawIdentitySettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(_drawIdentitySettings.value, "Identity Settings");
            if (_drawIdentitySettings.value)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUI.indentLevel++;
                UniqueGUID.stringValue = EditorGUILayoutGameUtility.GUIDField("Unique GUID", UniqueGUID.stringValue);
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // Draw Content
            _drawContent.value = EditorGUILayout.BeginFoldoutHeaderGroup(_drawContent.value, "Content");
            if (_drawContent.value)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUI.indentLevel++;

                GUILayout.Label("Defs", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(LevelSpawnNames, true);

                GUILayout.Label("Databases", EditorStyles.boldLabel);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Refresh Databases", GUILayout.Height(25)))
                {
                    _target.RefreshDatabases();
                }
                if (GUILayout.Button("Info", GUILayout.Height(25), GUILayout.Width(35)))
                {
                    SharedContentEditorWindow.ShowWindowOnCharacters();
                }

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(UniqueDatabases, true);
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // Draw extras
            EditorGUILayoutGameUtility.DrawTargetExtras(target);

            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        void ShowComponentCategories()
        {
            EditorGUI.BeginChangeCheck();

            var style = new GUIStyle("popup")
            {
                alignment = TextAnchor.MiddleCenter,
                fontStyle = FontStyle.Bold,
            };

            for (int i = 0; i < categories.Length; i++)
            {
                var category = categories[i];

                if (category.Components.Count == 0)
                {
                    continue;
                }

                if (i > 0)
                {
                    GUILayout.Space(5f);
                }

                BeginBox(CustomEditorStyles.ColoredBox(new Color(0.5f, 0.5f, 0.5f, 0.25f), 0));

                currentCategory = categories[i];

                ArrayFoldout(currentCategory.DummyValue,
                             currentCategory.Name.ToGUIContent(),
                             disableOnPlay: false,
                             foldoutDrawer: ShowComponentCategoryFoldout,
                             elementDrawer: ShowComponent,
                             onPreElementDraw: OnPreComponent,
                             onPostElementDraw: OnPostComponent,
                             deleteCallback: DeleteComponent,
                             reorderCallback: ReorderComponent);

                GUILayout.Space(4f);
                EndBox();
            }

            if (entity.GetAllComponents().Count > 0)
            {
                Separator();
            }

            int index = EditorGUILayout.Popup(0, AddOptions, style);

            if (EditorGUI.EndChangeCheck() && index > 0)
            {
                AddComponent(AddTypes[index]);
            }
        }