예제 #1
0
    protected override void DrawPropertyLayout(IPropertyValueEntry <Wall> entry, GUIContent label)
    {
        EditorGUI.BeginChangeCheck();
        var info = SirenixEditorFields.EnumDropdown(entry.Property.Info.PropertyName, entry.SmartValue.Info);

        if (EditorGUI.EndChangeCheck())
        {
            entry.SmartValue = new Wall(entry.SmartValue.buildingPosition, entry.SmartValue.direction, (WallInfo)info);
        }
    }
예제 #2
0
    protected override void DrawPropertyLayout(IPropertyValueEntry <Wall> entry, GUIContent label)
    {
        EditorGUI.BeginChangeCheck();
        var info = SirenixEditorFields.EnumDropdown("Info", entry.SmartValue.Info);

        if (EditorGUI.EndChangeCheck())
        {
            entry.SmartValue.Info = (WallInfo)info;
        }
    }
예제 #3
0
파일: EnumDrawer.cs 프로젝트: B-CK/P-Lua
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
 {
     if (GeneralDrawerConfig.Instance.UseImprovedEnumDropDown)
     {
         entry.SmartValue = EnumSelector <T> .DrawEnumField(label, entry.SmartValue);
     }
     else
     {
         entry.WeakSmartValue = SirenixEditorFields.EnumDropdown(label, (Enum)entry.WeakSmartValue);
     }
 }
예제 #4
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var  entry = this.ValueEntry;
            Rect rect  = EditorGUILayout.GetControlRect(label != null);

            //rect = EditorGUI.IndentedRect(rect);

            if (label != null)
            {
                rect = EditorGUI.PrefixLabel(rect, label);
            }

            const float arrowWidth = 20;

            var btnRightRect = rect.AlignRight(arrowWidth);
            var btnLeftRect  = btnRightRect;

            btnLeftRect.x       -= btnLeftRect.width;
            btnLeftRect.height  -= 1;
            btnRightRect.height -= 1;

            if (GUI.Button(btnLeftRect, GUIContent.none))
            {
                var names = Enum.GetNames(typeof(T));
                var name  = Enum.GetName(typeof(T), entry.SmartValue);

                var currNameIndex = (names as IList <string>).IndexOf(name);
                currNameIndex    = MathUtilities.Wrap(currNameIndex - 1, 0, names.Length);
                entry.SmartValue = (T)Enum.Parse(typeof(T), names[currNameIndex]);
            }

            if (GUI.Button(btnRightRect, GUIContent.none))
            {
                var names = Enum.GetNames(typeof(T));
                var name  = Enum.GetName(typeof(T), entry.SmartValue);

                var currNameIndex = (names as IList <string>).IndexOf(name);
                currNameIndex    = MathUtilities.Wrap(currNameIndex + 1, 0, names.Length);
                entry.SmartValue = (T)Enum.Parse(typeof(T), names[currNameIndex]);
            }

            EditorIcons.TriangleLeft.Draw(btnLeftRect.AlignCenter(16, 16));
            EditorIcons.TriangleRight.Draw(btnRightRect.AlignCenter(16, 16));

            rect.xMax -= btnRightRect.width * 2;

            entry.WeakSmartValue = SirenixEditorFields.EnumDropdown(rect, (Enum)entry.WeakSmartValue);
        }
예제 #5
0
    public override void OnInspectorGUI()
    {
        //EditorGUILayout.Space(20);
        //base.OnInspectorGUI();

        serializedObject.Update();

        //var editorType = typeof(Editor);
        //editorType.InvokeMember("DoDrawDefaultInspector",
        //    System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static
        //     | System.Reflection.BindingFlags.NonPublic, null, null,
        //    new object[] {serializedObject});
        //return;

        var emitter = target as ColliderSpawnEmitter;

        emitter.time        = EditorGUILayout.FloatField("Time", (float)emitter.time);
        emitter.retroactive = EditorGUILayout.Toggle("Retroactive", emitter.retroactive);
        emitter.emitOnce    = EditorGUILayout.Toggle("EmitOnce", emitter.emitOnce);
        EditorGUILayout.Space(20);
        emitter.ColliderName = EditorGUILayout.TextField("碰撞体名称", emitter.ColliderName);
        emitter.ColliderType = (ColliderType)SirenixEditorFields.EnumDropdown("碰撞体类型", emitter.ColliderType);
        if (emitter.ColliderType != ColliderType.TargetFly)
        {
            //emitter.ColliderShape = (ColliderShape)SirenixEditorFields.EnumDropdown("碰撞体形状", emitter.ColliderShape);
            emitter.ExistTime = EditorGUILayout.FloatField("存活时间", emitter.ExistTime);
        }

        emitter.EffectApplyType = (EffectApplyType)EditorGUILayout.EnumPopup("应用效果", emitter.EffectApplyType);

        serializedObject.ApplyModifiedProperties();
        if (!EditorUtility.IsDirty(emitter))
        {
            EditorUtility.SetDirty(emitter);
        }
    }
예제 #6
0
 /// <summary>
 /// Draws the property.
 /// </summary>
 protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label)
 {
     entry.WeakSmartValue = SirenixEditorFields.EnumDropdown(label, (Enum)entry.WeakSmartValue);
 }
예제 #7
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            // Limit valid characters.
            // TODO: This might not be necessary since name will need to be sanitized for different needs later (as an enum entry, pre-processor define, etc.)
            //char chr = Event.current.character;
            //if ((chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z') && (chr < '0' || chr > '9') && chr != '-' && chr != '_' && chr != ' ')
            //{
            //    Event.current.character = '\0';
            //}

            bool show = property.isExpanded;

            UnityBuildGUIUtility.DropdownHeader(property.FindPropertyRelative("typeName").stringValue, ref show, false);
            property.isExpanded = show;

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                GUILayout.Label("Basic Info", UnityBuildGUIUtility.midHeaderStyle);

                SerializedProperty typeName = property.FindPropertyRelative("typeName");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Type Name");
                typeName.stringValue = BuildProject.SanitizeFolderName(GUILayout.TextArea(typeName.stringValue));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(property.FindPropertyRelative("bundleIdentifier"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("productName"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("companyName"));
                EditorGUILayout.PropertyField(property.FindPropertyRelative("customDefines"));

                GUILayout.Space(10);
                GUILayout.Label("Build Options", UnityBuildGUIUtility.midHeaderStyle);

                SerializedProperty incrementalGC            = property.FindPropertyRelative("incrementalGC");
                SerializedProperty cppCompilerConfiguration = property.FindPropertyRelative("cppCompilerConfiguration");

                incrementalGC.boolValue = EditorGUILayout.ToggleLeft(" Use Incremental GC", incrementalGC.boolValue);
                cppCompilerConfiguration.enumValueIndex = (int)(CPPCompilerConfigurationType)SirenixEditorFields
                                                          .EnumDropdown(" C++ Compiler Configuration",
                                                                        (CPPCompilerConfigurationType)cppCompilerConfiguration.enumValueIndex,
                                                                        null);

                GUILayout.Space(10);
                GUILayout.Label("Debug Options", UnityBuildGUIUtility.midHeaderStyle);

                SerializedProperty developmentBuild       = property.FindPropertyRelative("developmentBuild");
                SerializedProperty allowDebugging         = property.FindPropertyRelative("allowDebugging");
                SerializedProperty waitForManagedDebugger = property.FindPropertyRelative("waitForManagedDebugger");
                SerializedProperty enableHeadlessMode     = property.FindPropertyRelative("enableHeadlessMode");

                EditorGUI.BeginDisabledGroup(enableHeadlessMode.boolValue);
                developmentBuild.boolValue = EditorGUILayout.ToggleLeft(" Development Build", developmentBuild.boolValue);
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(!developmentBuild.boolValue);
                allowDebugging.boolValue         = EditorGUILayout.ToggleLeft(" Script Debugging", allowDebugging.boolValue);
                waitForManagedDebugger.boolValue = EditorGUILayout.ToggleLeft(" Wait For Managed Debugger", waitForManagedDebugger.boolValue);
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(developmentBuild.boolValue);
                enableHeadlessMode.boolValue = EditorGUILayout.ToggleLeft(" Headless Mode", enableHeadlessMode.boolValue);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.PropertyField(property.FindPropertyRelative("sceneList"));

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Delete", GUILayout.MaxWidth(150)))
                {
                    BuildReleaseType[] types = BuildSettings.releaseTypeList.releaseTypes;
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (types[i].typeName == property.FindPropertyRelative("typeName").stringValue)
                        {
                            ArrayUtility.RemoveAt <BuildReleaseType>(ref BuildSettings.releaseTypeList.releaseTypes, i);
                            GUIUtility.keyboardControl = 0;
                            break;
                        }
                    }
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                property.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.EndVertical();
            }

            EditorGUI.EndProperty();
        }
 protected override TElement DrawElement(Rect rect, TElement value)
 {
     return((TElement)(object)SirenixEditorFields.EnumDropdown(rect.Padding(4), null, (Enum)(object)value, null));
 }