예제 #1
0
        public override void OnInspectorGUI()
        {
            CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target;

            bool microphoneEnabled = PlayerSettings.WSA.GetCapability(PlayerSettings.WSACapability.Microphone);

            if (!microphoneEnabled)
            {
                HUXEditorUtils.WarningMessage("Microphone capability not present. Speech recognition will be disabled.", "Enable Microphone Capability", EnableMicrophone);
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            HUXEditorUtils.BeginSectionBox("Keyword source");
            speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource);
            CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>();

            switch (speechButton.KeywordSource)
            {
            case CompoundButtonSpeech.KeywordSourceEnum.ButtonText:
            default:
                if (text == null)
                {
                    HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText);
                }
                else if (string.IsNullOrEmpty(text.Text))
                {
                    HUXEditorUtils.WarningMessage("No keyword found in button text.");
                }
                else
                {
                    EditorGUILayout.LabelField("Keyword: " + text.Text);
                }
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride:
                speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword);
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.None:
                HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)");
                break;
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target);
        }
        public override void OnInspectorGUI()
        {
            CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target;

            HUXEditorUtils.BeginSectionBox("Keyword source");
            speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource);
            CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>();

            switch (speechButton.KeywordSource)
            {
            case CompoundButtonSpeech.KeywordSourceEnum.ButtonText:
            default:
                if (text == null)
                {
                    HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText);
                }
                else if (string.IsNullOrEmpty(text.Text))
                {
                    HUXEditorUtils.WarningMessage("No keyword found in button text.");
                }
                else
                {
                    EditorGUILayout.LabelField("Keyword: " + text.Text);
                }
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride:
                speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword);
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.None:
                HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)");
                break;
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target);
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            AppBar appBar = (AppBar)target;

            appBar.DisplayType = (AppBar.AppBarDisplayTypeEnum)EditorGUILayout.EnumPopup("Display Type", appBar.DisplayType);

            if (appBar.DisplayType == AppBar.AppBarDisplayTypeEnum.Manipulation)
            {
                HUXEditorUtils.BeginSectionBox("Bounding box");
                appBar.BoundingBox = HUXEditorUtils.SceneObjectField <BoundingBoxManipulate>(null, appBar.BoundingBox);
                if (appBar.BoundingBox == null)
                {
                    HUXEditorUtils.WarningMessage("Manipulation state will not function correctly at runtime without a bounding box. (If you're using BoundingBoxTarget this is not a problem.)");
                }
                HUXEditorUtils.EndSectionBox();
            }

            HUXEditorUtils.BeginSectionBox("App bar options");
            appBar.HoverOffsetYScale  = EditorGUILayout.Slider("Hover Offset (Y)", appBar.HoverOffsetYScale, -1f, 2f);
            appBar.HoverOffsetZ       = EditorGUILayout.Slider("Hover Offset (Z)", appBar.HoverOffsetZ, 0f, 2f);
            appBar.SquareButtonPrefab = (GameObject)EditorGUILayout.ObjectField("Button Prefab", appBar.SquareButtonPrefab, typeof(GameObject));
            GUI.color = (appBar.CustomButtonIconProfile == null) ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor;
            appBar.CustomButtonIconProfile = (ButtonIconProfile)EditorGUILayout.ObjectField("Custom Icon Profile", appBar.CustomButtonIconProfile, typeof(ButtonIconProfile));
            HUXEditorUtils.DrawSubtleMiniLabel("(Leave blank to use the button's default profile)");
            GUI.color = HUXEditorUtils.DefaultColor;

            if (appBar.SquareButtonPrefab == null)
            {
                HUXEditorUtils.ErrorMessage("You must specify a button prefab");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            CompoundButtonIcon icon = appBar.SquareButtonPrefab.GetComponent <CompoundButtonIcon>();

            if (icon == null)
            {
                HUXEditorUtils.ErrorMessage("You must use a button prefab that has a CompoundButtonIcon component");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            HUXEditorUtils.BeginSubSectionBox("Default buttons");
            GUI.color        = appBar.UseHide ? HUXEditorUtils.DefaultColor : HUXEditorUtils.DisabledColor;
            appBar.UseHide   = EditorGUILayout.Toggle("Show / Hide Buttons", appBar.UseHide);
            GUI.color        = appBar.UseAdjust ? HUXEditorUtils.DefaultColor : HUXEditorUtils.DisabledColor;
            appBar.UseAdjust = EditorGUILayout.Toggle("Adjust / Done Buttons", appBar.UseAdjust);
            GUI.color        = appBar.UseRemove ? HUXEditorUtils.DefaultColor : HUXEditorUtils.DisabledColor;
            appBar.UseRemove = EditorGUILayout.Toggle("Remove Button", appBar.UseRemove);
            GUI.color        = HUXEditorUtils.DefaultColor;
            HUXEditorUtils.EndSubSectionBox();

            HUXEditorUtils.BeginSubSectionBox("Custom buttons");
            HUXEditorUtils.DrawSubtleMiniLabel("Up to " + AppBar.MaxCustomButtons + " allowed. Un-named buttons will be ignored.");
            //HUXEditorUtils.DrawProfileField <ButtonIconProfile> (appBar.CustomButtonIconProfile)

            // Get the profile we'll be using for our icons
            ButtonIconProfile profile = appBar.CustomButtonIconProfile;

            if (profile == null)
            {
                profile = icon.Profile;
                if (profile == null)
                {
                    HUXEditorUtils.ErrorMessage("The button prefab does not specify an icon profile. Can't continue.");
                    HUXEditorUtils.EndSectionBox();
                    return;
                }
            }

            AppBar.ButtonTemplate[] buttons = appBar.Buttons;
            if (buttons.Length != AppBar.MaxCustomButtons)
            {
                System.Array.Resize <AppBar.ButtonTemplate>(ref buttons, AppBar.MaxCustomButtons);
            }
            int numCustomButtons = appBar.UseHide ? 0 : -1;

            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i] = DrawButtonEditor(buttons[i], profile, ref numCustomButtons, "buttons", i);
            }
            appBar.Buttons = buttons;
            HUXEditorUtils.EndSubSectionBox();

            // Force the buttons to refresh based on the options we've specified
            appBar.EditorRefreshTemplates();

            HUXEditorUtils.BeginSubSectionBox("App bar preview");
            HUXEditorUtils.DrawSubtleMiniLabel("An approximation of what the final bar will look like. 'Hidden' and 'Manipulation' states depend on default button settings and may not be available.");
            previewState = (AppBar.AppBarStateEnum)EditorGUILayout.EnumPopup(previewState);
            List <AppBar.ButtonTemplate> buttonList = new List <AppBar.ButtonTemplate>();

            buttonList.AddRange(appBar.DefaultButtons);
            buttonList.AddRange(buttons);

            if (previewState == AppBar.AppBarStateEnum.Default)
            {
                buttonList.Sort(delegate(AppBar.ButtonTemplate b1, AppBar.ButtonTemplate b2) { return(b1.DefaultPosition.CompareTo(b2.DefaultPosition)); });
            }
            else
            {
                buttonList.Sort(delegate(AppBar.ButtonTemplate b1, AppBar.ButtonTemplate b2) { return(b1.ManipulationPosition.CompareTo(b2.ManipulationPosition)); });
            }


            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.MaxHeight(previewButtonSize + 15f));
            EditorGUILayout.BeginHorizontal();
            bool drewOneButton = false;

            for (int i = 0; i < buttonList.Count; i++)
            {
                drewOneButton |= DrawPreviewButton(buttonList[i], previewState, appBar.UseHide, appBar.UseAdjust, appBar.UseRemove);
            }
            if (!drewOneButton)
            {
                HUXEditorUtils.WarningMessage("This state has no buttons due to the options you've chosen. It won't be permitted during play mode.");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();

            HUXEditorUtils.EndSubSectionBox();

            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(appBar);
        }
예제 #4
0
        public override void OnInspectorGUI()
        {
            BoundingBoxManipulate bbm = (BoundingBoxManipulate)target;

            GUI.color = HUXEditorUtils.DefaultColor;

            bbm.Target = (GameObject)EditorGUILayout.ObjectField("Target", bbm.Target, typeof(GameObject), true);
            //bbm.ActiveHandle = (BoundingBoxHandle)EditorGUILayout.ObjectField("Active Handle", bbm.ActiveHandle, typeof(BoundingBoxHandle), true);

            HUXEditorUtils.BeginSectionBox("Settings");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bounds method", GUILayout.MaxWidth(100));
            bbm.BoundsCalculationMethod = (BoundingBox.BoundsCalculationMethodEnum)EditorGUILayout.EnumPopup(bbm.BoundsCalculationMethod, GUILayout.MaxWidth(155));
            switch (bbm.BoundsCalculationMethod)
            {
            case BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all MeshFilters to calculate bounds. This setting is more accurate (especially for flat objects), but will only calculate bounds for mesh-based objects.");
                break;

            case BoundingBox.BoundsCalculationMethodEnum.RendererBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all Renderers to calculate bounds. This setting is less accurate, but can calculate bounds for objects like particle systems.");
                break;
            }
            EditorGUILayout.EndHorizontal();
            bbm.PhysicsLayer = EditorGUILayout.IntSlider("Physics / Rendering Layer", bbm.PhysicsLayer, 0, 32);
            bbm.IgnoreLayer  = EditorGUILayout.IntSlider("Ignore Mesh Renderers on this Layer", bbm.IgnoreLayer, 0, 32);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Manipulation");
            bbm.DragMultiplier     = EditorGUILayout.Slider("Drag input scale", bbm.DragMultiplier, 0.01f, 20f);
            bbm.RotateMultiplier   = EditorGUILayout.Slider("Rotation input scale", bbm.RotateMultiplier, 0.01f, 20f);
            bbm.ScaleMultiplier    = EditorGUILayout.Slider("Scale input scale", bbm.ScaleMultiplier, 0.01f, 20f);
            bbm.MinScalePercentage = EditorGUILayout.Slider("Minimum scale per operation", bbm.MinScalePercentage, 0.05f, 1f);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Flattening");
            bbm.FlattenPreference = (BoundingBox.FlattenModeEnum)EditorGUILayout.EnumPopup("Flattening preference", bbm.FlattenPreference);
            switch (bbm.FlattenPreference)
            {
            case BoundingBox.FlattenModeEnum.DoNotFlatten:
                HUXEditorUtils.DrawSubtleMiniLabel("Bounding box will never be flattened no matter how thin the target object gets.");
                break;

            case BoundingBox.FlattenModeEnum.FlattenAuto:
                HUXEditorUtils.DrawSubtleMiniLabel("If an axis drops below the relative % threshold, that axis will be flattened to the specified thickness.");
                bbm.FlattenAxisThreshold   = EditorGUILayout.Slider("Flatten axis threshold %", (bbm.FlattenAxisThreshold * 100), 0.01f, 100f) / 100;
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                EditorGUILayout.EnumPopup("Current flattened axis: ", bbm.FlattenedAxis);
                break;

            case BoundingBox.FlattenModeEnum.FlattenX:
            case BoundingBox.FlattenModeEnum.FlattenY:
            case BoundingBox.FlattenModeEnum.FlattenZ:
                HUXEditorUtils.DrawSubtleMiniLabel("The selected axis will be flattened to the specified thickness.");
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                break;
            }
            HUXEditorUtils.EndSubSectionBox();

            bbm.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>(
                "Permitted Operations",
                bbm.PermittedOperations,
                "Default",
                BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag,
                BoundingBoxManipulate.OperationEnum.Drag);

            if (!Application.isPlaying)
            {
                bbm.AcceptInput     = EditorGUILayout.Toggle("Accept Input", bbm.AcceptInput);
                bbm.ManipulatingNow = EditorGUILayout.Toggle("Manipulating Now", bbm.ManipulatingNow);
            }

            HUXEditorUtils.SaveChanges(bbm);
        }
예제 #5
0
        public override void OnInspectorGUI()
        {
            SimpleMenuCollection menu = (SimpleMenuCollection)target;

            HUXEditorUtils.BeginSectionBox("Menu settings");

            menu.DisplayTitle = EditorGUILayout.Toggle("Display Title", menu.DisplayTitle);
            if (menu.DisplayTitle)
            {
                //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false);
                menu.Title     = EditorGUILayout.TextArea(menu.Title);
                menu.TitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Title TextMesh", menu.TitleText, menu.transform);
            }

            menu.DisplaySubtitle = EditorGUILayout.Toggle("Display Subtitle", menu.DisplaySubtitle);
            if (menu.DisplaySubtitle)
            {
                //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false);
                menu.Subtitle     = EditorGUILayout.TextArea(menu.Subtitle);
                menu.SubtitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Subtitle TextMesh", menu.SubtitleText, menu.transform);
            }
            menu.ButtonPrefab     = (GameObject)EditorGUILayout.ObjectField("Button prefab", menu.ButtonPrefab, typeof(GameObject), false);
            menu.ParentCollection = HUXEditorUtils.DropDownComponentField <ObjectCollection>("Collection parent", menu.ParentCollection, menu.transform);

            if (menu.ButtonPrefab == null)
            {
                HUXEditorUtils.ErrorMessage("You must specify a button prefab");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            if (menu.ParentCollection == null)
            {
                HUXEditorUtils.ErrorMessage("This menu needs a collection component to work", AddCollection, "Fix");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            bool showIcon = false;
            bool showText = false;

            CompoundButtonIcon icon = menu.ButtonPrefab.GetComponent <CompoundButtonIcon>();

            showIcon = icon != null;


            CompoundButtonText text = menu.ButtonPrefab.GetComponent <CompoundButtonText>();

            showText = text != null;

            ButtonIconProfile profile = null;

            if (icon != null)
            {
                profile = icon.IconProfile;
            }

            HUXEditorUtils.BeginSubSectionBox("Buttons");
            HUXEditorUtils.DrawSubtleMiniLabel("Up to " + SimpleMenuCollection.MaxButtons + " allowed. Un-named buttons will be ignored.");

            SimpleMenuCollectionButton[] buttons          = menu.Buttons;
            HashSet <string>             buttonNamesSoFar = new HashSet <string>();
            int numButtons = 0;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (!buttons[i].IsEmpty)
                {
                    numButtons++;
                }
                DrawButtonEditor(buttons[i], showIcon, showText, profile, "buttons", i, buttonNamesSoFar);
            }
            HUXEditorUtils.EndSubSectionBox();

            menu.EditorRefreshButtons();

            HUXEditorUtils.BeginSubSectionBox("Menu preview");
            HUXEditorUtils.DrawSubtleMiniLabel("An approximation of what the menu will look like.");

            List <SimpleMenuCollectionButton> buttonsList = new List <SimpleMenuCollectionButton>(buttons);

            buttonsList.Sort(delegate(SimpleMenuCollectionButton b1, SimpleMenuCollectionButton b2) { return(b1.Index.CompareTo(b2.Index)); });

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.MinHeight(previewButtonSizeY * numButtons + 50f));
            EditorGUILayout.BeginVertical();
            bool drewOneButton = false;

            foreach (SimpleMenuCollectionButton button in buttonsList)
            {
                drewOneButton |= DrawPreviewButton(button, showText);
            }
            if (!drewOneButton)
            {
                HUXEditorUtils.WarningMessage("This state has no buttons due to the options you've chosen. It won't be permitted during play mode.");
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            HUXEditorUtils.EndSubSectionBox();

            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(menu);
        }
        public override void OnInspectorGUI()
        {
            CompoundButtonToggle toggle = (CompoundButtonToggle)target;

            HUXEditorUtils.BeginSectionBox("Target");

            toggle.Target = HUXEditorUtils.DropDownComponentField <MonoBehaviour>("Component", toggle.Target, toggle.transform, true);
            FieldInfo fieldInfo   = null;
            Type      profileType = null;

            if (toggle.Target == null)
            {
                HUXEditorUtils.ErrorMessage("Target must be set.");
                HUXEditorUtils.EndSectionBox();
                HUXEditorUtils.SaveChanges(target, serializedObject);
                return;
            }
            else
            {
                fieldInfo = toggle.Target.GetType().GetField("Profile");

                if (fieldInfo == null)
                {
                    HUXEditorUtils.ErrorMessage("Target component has no 'Profile' field - are you use this class inherits from ProfileButtonBase?");
                    HUXEditorUtils.EndSectionBox();
                    HUXEditorUtils.SaveChanges(target, serializedObject);
                    return;
                }

                GUIStyle labelStyle = new GUIStyle(EditorStyles.label);
                labelStyle.fontSize  = 18;
                labelStyle.fontStyle = FontStyle.Bold;

                profileType = fieldInfo.FieldType;
                EditorGUILayout.LabelField("Type: " + toggle.Target.GetType().Name + " / " + fieldInfo.FieldType.Name, labelStyle, GUILayout.MinHeight(24));
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Toggling");
            HUXEditorUtils.DrawSubtleMiniLabel("Select on/off profiles of the type " + profileType.Name);
            if (toggle.OnProfile == null)
            {
                toggle.OnProfile = (ButtonProfile)fieldInfo.GetValue(toggle.Target);
            }
            if (toggle.OffProfile == null)
            {
                toggle.OffProfile = toggle.OnProfile;
            }
            ButtonProfile onProfile  = (ButtonProfile)EditorGUILayout.ObjectField("On Profile", toggle.OnProfile, typeof(ButtonProfile), false);
            ButtonProfile offProfile = (ButtonProfile)EditorGUILayout.ObjectField("Off Profile", toggle.OffProfile, typeof(ButtonProfile), false);

            if (onProfile.GetType() == profileType)
            {
                toggle.OnProfile = onProfile;
            }
            if (offProfile.GetType() == profileType)
            {
                toggle.OffProfile = offProfile;
            }

            if (toggle.OnProfile.GetType() != profileType)
            {
                HUXEditorUtils.ErrorMessage("On profile object does not match type " + profileType.Name);
            }
            if (toggle.OffProfile.GetType() != profileType)
            {
                HUXEditorUtils.ErrorMessage("Off profile object does not match type " + profileType.Name);
            }

            if (onProfile == offProfile)
            {
                HUXEditorUtils.WarningMessage("Profiles are the same - toggle will have no effect");
            }

            toggle.Behavior = (CompoundButtonToggle.ToggleBehaviorEnum)EditorGUILayout.EnumPopup("Toggle behavior", toggle.Behavior);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("State");
            if (!Application.isPlaying)
            {
                toggle.State = EditorGUILayout.Toggle(toggle.State);
            }
            else
            {
                EditorGUILayout.Toggle(toggle.State);
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
        public override void OnInspectorGUI()
        {
            CompoundButtonMesh meshButton = (CompoundButtonMesh)target;

            GUI.color          = HUXEditorUtils.DefaultColor;
            meshButton.Profile = HUXEditorUtils.DrawProfileField <ButtonMeshProfile>(meshButton.Profile);

            if (meshButton.Profile == null)
            {
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            HUXEditorUtils.BeginSectionBox("Target objects");
            meshButton.TargetTransform = HUXEditorUtils.DropDownComponentField <Transform> ("Transform", meshButton.TargetTransform, meshButton.transform);
            if (meshButton.TargetTransform != null && meshButton.TargetTransform == meshButton.transform)
            {
                HUXEditorUtils.WarningMessage("Button may behave strangely if scale & offset is applied to transform root. Consider choosing a child transform.");
            }
            else if (meshButton.TargetTransform != null)
            {
                // Check to see if offset & scale match any of the button defaults
                bool foundCloseState = false;
                foreach (CompoundButtonMesh.MeshButtonDatum datum in meshButton.Profile.ButtonStates)
                {
                    if (meshButton.TargetTransform.localPosition == datum.Offset && meshButton.TargetTransform.localScale == datum.Scale)
                    {
                        foundCloseState = true;
                        break;
                    }
                }
                if (!foundCloseState)
                {
                    HUXEditorUtils.WarningMessage("Transform doesn't match the scale / offset of any button states. Button may appear different at runtime.");
                }
            }

            GUI.color           = HUXEditorUtils.DefaultColor;
            meshButton.Renderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Mesh Renderer", meshButton.Renderer, meshButton.transform);
            //meshButton.MeshFilter = HUXEditorUtils.DropDownComponentField<MeshFilter>("Mesh Filter", meshButton.MeshFilter, meshButton.transform);

            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Target material properties", (meshButton.Renderer == null ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor));
            if (meshButton.Renderer == null)
            {
                HUXEditorUtils.DrawSubtleMiniLabel("(No renderer specified)");
            }
            else
            {
                meshButton.Profile.ColorPropertyName = HUXEditorUtils.MaterialPropertyName(
                    meshButton.Profile.ColorPropertyName,
                    meshButton.Renderer.sharedMaterial,
                    ShaderUtil.ShaderPropertyType.Color);

                meshButton.Profile.ValuePropertyName = HUXEditorUtils.MaterialPropertyName(
                    meshButton.Profile.ValuePropertyName,
                    meshButton.Renderer.sharedMaterial,
                    ShaderUtil.ShaderPropertyType.Float);
            }

            HUXEditorUtils.EndSectionBox();

            // Draw the profile
            HUXEditorUtils.DrawProfileInspector(meshButton.Profile, meshButton);

            HUXEditorUtils.SaveChanges(target, meshButton.Profile);
        }
        public override void OnInspectorGUI()
        {
            BoundingBox bbm = (BoundingBox)target;

            GUI.color = HUXEditorUtils.DefaultColor;

            bbm.Target = (GameObject)EditorGUILayout.ObjectField("Target", bbm.Target, typeof(GameObject), true);
            //bbm.ActiveHandle = (BoundingBoxHandle)EditorGUILayout.ObjectField("Active Handle", bbm.ActiveHandle, typeof(BoundingBoxHandle), true);

            HUXEditorUtils.BeginSectionBox("Settings");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bounds method", GUILayout.MaxWidth(100));
            bbm.BoundsCalculationMethod = (BoundingBox.BoundsCalculationMethodEnum)EditorGUILayout.EnumPopup(bbm.BoundsCalculationMethod, GUILayout.MaxWidth(155));
            switch (bbm.BoundsCalculationMethod)
            {
            case BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all MeshFilters to calculate bounds. This setting is more accurate (especially for flat objects), but will only calculate bounds for mesh-based objects.");
                break;

            case BoundingBox.BoundsCalculationMethodEnum.Colliders:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all Colliders to calculate bounds. This setting is best if you want precise manual control over bounds size.");
                break;

            case BoundingBox.BoundsCalculationMethodEnum.RendererBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all Renderers to calculate bounds. This setting is less accurate, but can calculate bounds for objects like particle systems.");
                break;
            }
            EditorGUILayout.EndHorizontal();
            bbm.PhysicsLayer = EditorGUILayout.IntSlider("Physics / Rendering Layer", bbm.PhysicsLayer, 0, 32);
            bbm.IgnoreLayer  = EditorGUILayout.IntSlider("Ignore Mesh Renderers on this Layer", bbm.IgnoreLayer, 0, 32);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Flattening");
            bbm.FlattenPreference = (BoundingBox.FlattenModeEnum)EditorGUILayout.EnumPopup("Flattening preference", bbm.FlattenPreference);
            switch (bbm.FlattenPreference)
            {
            case BoundingBox.FlattenModeEnum.DoNotFlatten:
                HUXEditorUtils.DrawSubtleMiniLabel("Bounding box will never be flattened no matter how thin the target object gets.");
                break;

            case BoundingBox.FlattenModeEnum.FlattenAuto:
                HUXEditorUtils.DrawSubtleMiniLabel("If an axis drops below the relative % threshold, that axis will be flattened to the specified thickness.");
                bbm.FlattenAxisThreshold   = EditorGUILayout.Slider("Flatten axis threshold %", (bbm.FlattenAxisThreshold * 100), 0.01f, 100f) / 100;
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                break;

            case BoundingBox.FlattenModeEnum.FlattenX:
            case BoundingBox.FlattenModeEnum.FlattenY:
            case BoundingBox.FlattenModeEnum.FlattenZ:
                HUXEditorUtils.DrawSubtleMiniLabel("The selected axis will be flattened to the specified thickness.");
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                break;
            }
            HUXEditorUtils.EndSubSectionBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
예제 #9
0
        public override void OnInspectorGUI()
        {
            ButtonMeshProfile  meshProfile = (ButtonMeshProfile)target;
            CompoundButtonMesh meshButton  = (CompoundButtonMesh)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            // Draw an editor for each state datum
            meshProfile.SmoothStateChanges = EditorGUILayout.Toggle("Smooth state changes", meshProfile.SmoothStateChanges);
            if (meshProfile.SmoothStateChanges)
            {
                meshProfile.AnimationSpeed = EditorGUILayout.Slider("Animation speed", meshProfile.AnimationSpeed, 0.01f, 1f);
            }
            meshProfile.StickyPressedEvents = EditorGUILayout.Toggle("'Sticky' pressed events", meshProfile.StickyPressedEvents);
            if (meshProfile.StickyPressedEvents)
            {
                meshProfile.StickyPressedTime = EditorGUILayout.Slider("'Sticky' pressed event time", meshProfile.StickyPressedTime, 0.01f, 1f);
            }

            // Validate our button states - ensure there's one for each button state enum value
            Button.ButtonStateEnum[] buttonStates = (Button.ButtonStateEnum[])System.Enum.GetValues(typeof(Button.ButtonStateEnum));
            List <CompoundButtonMesh.MeshButtonDatum> missingStates = new List <CompoundButtonMesh.MeshButtonDatum>();

            foreach (Button.ButtonStateEnum buttonState in buttonStates)
            {
                bool foundState = false;
                foreach (CompoundButtonMesh.MeshButtonDatum datum in meshProfile.ButtonStates)
                {
                    if (datum.ActiveState == buttonState)
                    {
                        foundState = true;
                        break;
                    }
                }

                if (!foundState)
                {
                    CompoundButtonMesh.MeshButtonDatum missingState = new CompoundButtonMesh.MeshButtonDatum(buttonState);
                    missingState.Name = buttonState.ToString();
                    missingStates.Add(missingState);
                }
            }

            // If any were missing, add them to our button states
            // They may be out of order but we don't care
            if (missingStates.Count > 0)
            {
                missingStates.AddRange(meshProfile.ButtonStates);
                meshProfile.ButtonStates = missingStates.ToArray();
            }

            foreach (CompoundButtonMesh.MeshButtonDatum datum in meshProfile.ButtonStates)
            {
                HUXEditorUtils.BeginSubSectionBox(datum.ActiveState.ToString());
                //datum.Name = EditorGUILayout.TextField("Name", datum.Name);
                if (meshButton != null && meshButton.TargetTransform == null)
                {
                    HUXEditorUtils.DrawSubtleMiniLabel("(No target transform specified for scale / offset)");
                }
                else
                {
                    datum.Offset = EditorGUILayout.Vector3Field("Offset", datum.Offset);
                    datum.Scale  = EditorGUILayout.Vector3Field("Scale", datum.Scale);

                    if (datum.Scale == Vector3.zero)
                    {
                        GUI.color = HUXEditorUtils.WarningColor;
                        if (GUILayout.Button("Warning: Button state scale is zero. Click here to fix.", EditorStyles.miniButton))
                        {
                            datum.Scale = Vector3.one;
                        }
                    }
                }

                GUI.color = HUXEditorUtils.DefaultColor;
                if (meshButton != null && meshButton.Renderer == null)
                {
                    HUXEditorUtils.DrawSubtleMiniLabel("(No target renderer specified for color / value material properties)");
                }
                else
                {
                    if (!string.IsNullOrEmpty(meshProfile.ColorPropertyName))
                    {
                        datum.StateColor = EditorGUILayout.ColorField(meshProfile.ColorPropertyName + " value", datum.StateColor);
                    }
                    if (!string.IsNullOrEmpty(meshProfile.ValuePropertyName))
                    {
                        datum.StateValue = EditorGUILayout.FloatField(meshProfile.ValuePropertyName + " value", datum.StateValue);
                    }
                }
                HUXEditorUtils.EndSubSectionBox();
            }

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(this);
        }