public override void OnInspectorGUI()
        {
            ButtonSoundProfile soundProfile = (ButtonSoundProfile)target;

            //CompoundButtonSounds soundButton = (CompoundButtonSounds)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            DrawClipEditor(ref soundProfile.ButtonPressed, ref soundProfile.ButtonPressedVolume, "Button Pressed");
            DrawClipEditor(ref soundProfile.ButtonTargeted, ref soundProfile.ButtonTargetedVolume, "Button Targeted");
            DrawClipEditor(ref soundProfile.ButtonHeld, ref soundProfile.ButtonHeldVolume, "Button Held");
            DrawClipEditor(ref soundProfile.ButtonReleased, ref soundProfile.ButtonReleasedVolume, "Button Released");
            DrawClipEditor(ref soundProfile.ButtonCancelled, ref soundProfile.ButtonCancelledVolume, "Button Cancelled");
            DrawClipEditor(ref soundProfile.ButtonObservation, ref soundProfile.ButtonObservationVolume, "Button Observation");
            DrawClipEditor(ref soundProfile.ButtonObservationTargeted, ref soundProfile.ButtonObservationTargetedVolume, "Button Observation Targeted");

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            ButtonIconProfileFont iconProfile = (ButtonIconProfileFont)target;

            //CompoundButtonIcon iconButton = (CompoundButtonIcon)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            HUXEditorUtils.BeginSectionBox(ButtonIconProfileFont.DefaultUnicodeFont + " font asset");
            EditorGUILayout.BeginHorizontal();
            Font font = (Font)EditorGUILayout.ObjectField(iconProfile.IconFont, typeof(Font), false);

            EditorGUILayout.EndHorizontal();
            if (font == null)
            {
                HUXEditorUtils.ErrorMessage(
                    "You must assign the '" + ButtonIconProfileFont.DefaultUnicodeFont + "' font for this profile to work. (If the font is installed, clicking 'Auto-assign' will find it for you.)",
                    SearchForFont,
                    "Auto-assign '" + ButtonIconProfileFont.DefaultUnicodeFont + "' font");
                if (GUILayout.Button("Download '" + ButtonIconProfileFont.DefaultUnicodeFont + "' font"))
                {
                    Application.OpenURL(StartupChecks.RequiredFontURL);
                }
            }
            else
            {
                bool correctFontName = false;
                foreach (string fontName in font.fontNames)
                {
                    if (fontName.Equals(ButtonIconProfileFont.DefaultUnicodeFont))
                    {
                        correctFontName = true;
                        break;
                    }
                }
                if (correctFontName)
                {
                    // We've got the right font, now check its properties
                    iconProfile.IconFont = font;
                    if (!font.dynamic)
                    {
                        HUXEditorUtils.ErrorMessage("Font character mode must be set to 'Dynamic'", SelectFontAsset, "Click to open font asset");
                    }
                }
                else
                {
                    // This is the wrong font, don't use it
                    iconProfile.IconFont = null;
                }
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Material & mesh properties");
            iconProfile._IconNotFound_       = (Texture2D)EditorGUILayout.ObjectField("Icon not found texture", iconProfile._IconNotFound_, typeof(Texture2D), false, GUILayout.MaxHeight(35f), GUILayout.MaxHeight(35f));
            iconProfile.IconMesh             = (Mesh)EditorGUILayout.ObjectField("Icon mesh", iconProfile.IconMesh, typeof(Mesh), false);
            iconProfile.IconMaterial         = (Material)EditorGUILayout.ObjectField("Icon material", iconProfile.IconMaterial, typeof(Material), false);
            iconProfile.AlphaColorProperty   = HUXEditorUtils.MaterialPropertyName(iconProfile.AlphaColorProperty, iconProfile.IconMaterial, ShaderUtil.ShaderPropertyType.Color);
            iconProfile.AlphaTransitionSpeed = EditorGUILayout.Slider("Alpha Transition Speed", iconProfile.AlphaTransitionSpeed, 0f, 2f);
            iconProfile.FontScaleFactor      = EditorGUILayout.IntField("Font scale factor", iconProfile.FontScaleFactor);
            iconProfile.RendererScale        = EditorGUILayout.FloatField("Renderer scale", iconProfile.RendererScale);
            HUXEditorUtils.EndSectionBox();

            #region font selection

            //iconProfile.FontSize = EditorGUILayout.IntField("Size", Mathf.Clamp (iconProfile.FontSize, 10, 300));

            /*string[] osInstalledFontNames = Font.GetOSInstalledFontNames();
             * int huxIconFontNameIndex = -1;
             * for (int i = 0; i < osInstalledFontNames.Length; i++)
             * {
             *  if (osInstalledFontNames[i] == ButtonIconProfileFont.DefaultUnicodeFont)
             *  {
             *      huxIconFontNameIndex = i;
             *  }
             * }
             *
             * if (huxIconFontNameIndex < 0)
             * {
             *  HUXEditorUtils.ErrorMessage("Couldn't find font '" + ButtonIconProfileFont.DefaultUnicodeFont + "'", null);
             * }
             * else if (GUILayout.Button("Click to select '" + ButtonIconProfileFont.DefaultUnicodeFont + "'"))
             * {
             *  iconProfile.OSFontName = osInstalledFontNames[huxIconFontNameIndex];
             * }
             *
             * HUXEditorUtils.EndSectionBox();*/

            #endregion

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(this);
        }
        public override void OnInspectorGUI()
        {
            ButtonIconProfileTexture iconProfile = (ButtonIconProfileTexture)target;
            CompoundButtonIcon       iconButton  = (CompoundButtonIcon)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            HUXEditorUtils.BeginSectionBox("Material & mesh properties");
            iconProfile._IconNotFound_       = (Texture2D)EditorGUILayout.ObjectField("Icon not found texture", iconProfile._IconNotFound_, typeof(Texture2D), false, GUILayout.MaxHeight(35f), GUILayout.MaxHeight(35f));
            iconProfile.IconMesh             = (Mesh)EditorGUILayout.ObjectField("Icon mesh", iconProfile.IconMesh, typeof(Mesh), false);
            iconProfile.IconMaterial         = (Material)EditorGUILayout.ObjectField("Icon material", iconProfile.IconMaterial, typeof(Material), false);
            iconProfile.AlphaColorProperty   = HUXEditorUtils.MaterialPropertyName(iconProfile.AlphaColorProperty, iconProfile.IconMaterial, ShaderUtil.ShaderPropertyType.Color, false);
            iconProfile.AlphaTransitionSpeed = EditorGUILayout.Slider("Alpha Transition Speed", iconProfile.AlphaTransitionSpeed, 0f, 2f);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Textures defined in profile");
            if (iconButton == null || showTextures)
            {
                var properties = iconProfile.GetType().GetFields();
                foreach (var property in properties)
                {
                    if (property.FieldType == typeof(Texture2D) && !property.Name.StartsWith("_"))
                    {
                        Texture2D iconVal = (Texture2D)property.GetValue(iconProfile);
                        iconVal = (Texture2D)EditorGUILayout.ObjectField(property.Name, iconVal, typeof(Texture2D), false, GUILayout.MaxHeight(textureSize));
                        property.SetValue(iconProfile, iconVal);
                    }
                }
                HUXEditorUtils.EndSectionBox();

                HUXEditorUtils.BeginSectionBox("Custom texture array");
                if (GUILayout.Button("Add custom icon"))
                {
                    System.Array.Resize <Texture2D>(ref iconProfile.CustomIcons, iconProfile.CustomIcons.Length + 1);
                }
                for (int i = 0; i < iconProfile.CustomIcons.Length; i++)
                {
                    Texture2D icon = iconProfile.CustomIcons[i];
                    icon = (Texture2D)EditorGUILayout.ObjectField(icon != null ? icon.name : "(Empty)", icon, typeof(Texture2D), false, GUILayout.MaxHeight(textureSize));
                    iconProfile.CustomIcons[i] = icon;
                }
                if (iconButton != null)
                {
                    if (GUILayout.Button("Hide icon textures"))
                    {
                        showTextures = false;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Show icon textures"))
                {
                    showTextures = true;
                }
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
        public override void OnInspectorGUI()
        {
            ButtonTextProfile  textProfile = (ButtonTextProfile)target;
            CompoundButtonText textButton  = (CompoundButtonText)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            HUXEditorUtils.BeginSectionBox("Text properties");

            textProfile.Font      = (Font)EditorGUILayout.ObjectField("Font", textProfile.Font, typeof(Font), false);
            textProfile.Alignment = (TextAlignment)EditorGUILayout.EnumPopup("Alignment", textProfile.Alignment);
            if (textButton == null || !textButton.OverrideAnchor)
            {
                textProfile.Anchor = (TextAnchor)EditorGUILayout.EnumPopup("Anchor", textProfile.Anchor);
            }
            if (textButton == null || !textButton.OverrideFontStyle)
            {
                textProfile.Style = (FontStyle)EditorGUILayout.EnumPopup("Style", textProfile.Style);
            }
            if (textButton == null || !textButton.OverrideSize)
            {
                textProfile.Size = EditorGUILayout.IntField("Size", textProfile.Size);
            }
            textProfile.Color = EditorGUILayout.ColorField(textProfile.Color);

            HUXEditorUtils.EndSectionBox();


            HUXEditorUtils.BeginSectionBox("Text Offset (based on anchor setting)");
            if (textButton == null || !textButton.OverrideOffset)
            {
                switch (textProfile.Anchor)
                {
                case TextAnchor.LowerCenter:
                    textProfile.AnchorLowerCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset);
                    break;

                case TextAnchor.LowerLeft:
                    textProfile.AnchorLowerLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset);
                    break;

                case TextAnchor.LowerRight:
                    textProfile.AnchorLowerRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset);
                    break;

                case TextAnchor.MiddleCenter:
                    textProfile.AnchorMiddleCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset);
                    break;

                case TextAnchor.MiddleLeft:
                    textProfile.AnchorMiddleLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset);
                    break;

                case TextAnchor.MiddleRight:
                    textProfile.AnchorMiddleRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset);
                    break;

                case TextAnchor.UpperCenter:
                    textProfile.AnchorUpperCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset);
                    break;

                case TextAnchor.UpperLeft:
                    textProfile.AnchorUpperLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset);
                    break;

                case TextAnchor.UpperRight:
                    textProfile.AnchorUpperRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset);
                    break;
                }
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
Example #5
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);
        }