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); 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); 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); 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); }
public override void OnInspectorGUI() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; // See if there's a bounding box yet BoundingBoxManipulate bbm = GameObject.FindObjectOfType <BoundingBoxManipulate>(); AppBar toolbar = GameObject.FindObjectOfType <AppBar>(); if (bbm == null || toolbar == null) { HUXEditorUtils.ErrorMessage( "Couldn't find a bounding box prefab and/or manipulation toolbar in the scene. Bounding box target won't work without them.", AddBoundingBox); } HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(bbt); }
public override void OnInspectorGUI() { CompoundButtonSounds soundButton = (CompoundButtonSounds)target; GUI.color = Color.white; soundButton.SoundProfile = HUXEditorUtils.DrawProfileField <ButtonSoundProfile>(soundButton.SoundProfile); if (soundButton.SoundProfile == null) { HUXEditorUtils.SaveChanges(target); return; } HUXEditorUtils.DrawProfileInspector(soundButton.SoundProfile, soundButton); }
public override void OnInspectorGUI() { InteractionManager interactionManager = (InteractionManager)target; interactionManager.RecognizableGesures = (UnityEngine.XR.WSA.Input.GestureSettings)HUXEditorUtils.EnumCheckboxField <UnityEngine.XR.WSA.Input.GestureSettings>( "Recognizable gestures", interactionManager.RecognizableGesures, "Default", UnityEngine.XR.WSA.Input.GestureSettings.Tap | UnityEngine.XR.WSA.Input.GestureSettings.DoubleTap | UnityEngine.XR.WSA.Input.GestureSettings.Hold | UnityEngine.XR.WSA.Input.GestureSettings.NavigationX | UnityEngine.XR.WSA.Input.GestureSettings.NavigationY); HUXEditorUtils.SaveChanges(target, serializedObject); }
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() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(bbt); }
public override void OnInspectorGUI() { CompoundButtonSounds soundButton = (CompoundButtonSounds)target; GUI.color = Color.white; profileProp.objectReferenceValue = HUXEditorUtils.DrawProfileField <ButtonSoundProfile>(profileProp.objectReferenceValue as ButtonSoundProfile); if (soundButton.Profile == null) { HUXEditorUtils.SaveChanges(target, serializedObject); return; } HUXEditorUtils.DrawProfileInspector(soundButton.Profile, soundButton); HUXEditorUtils.SaveChanges(target, serializedObject); serializedObject.ApplyModifiedProperties(); }
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); }
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); }
public override void OnInspectorGUI() { if (!EditorApplication.isPlaying) { return; } KeywordManager keywordManager = (KeywordManager)target; HUXEditorUtils.BeginSectionBox("Registered keywords"); foreach (KeyValuePair <string, List <string> > command in keywordManager.EditorCommandDescriptions) { HUXEditorUtils.BeginSubSectionBox(command.Key); foreach (string commandTarget in command.Value) { EditorGUILayout.LabelField(commandTarget, EditorStyles.wordWrappedLabel); } HUXEditorUtils.EndSubSectionBox(); } HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target, serializedObject); }
public override void OnInspectorGUI() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); /*EditorGUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("Bounds method", GUILayout.MaxWidth(100)); * bbt.BoundsCalculationMethod = (BoundingBox.BoundsCalculationMethodEnum)EditorGUILayout.EnumPopup(bbt.BoundsCalculationMethod, GUILayout.MaxWidth(155)); * switch (bbt.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();*/ bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.FlattenPreference = (BoundingBox.FlattenModeEnum)EditorGUILayout.EnumPopup("Flattening mode", bbt.FlattenPreference); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(target, serializedObject); }
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() { 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); }
private bool DrawPreviewButton(AppBar.ButtonTemplate template, AppBar.AppBarStateEnum state, bool useHide, bool useAdjust, bool useRemove) { bool drewButton = false; if (template.IsEmpty) { return(drewButton); } if (buttonPreviewStyle == null) { buttonPreviewStyle = new GUIStyle(EditorStyles.toolbarButton); buttonPreviewStyle.fontSize = 8; buttonPreviewStyle.fixedHeight = previewButtonSize; buttonPreviewStyle.fixedWidth = previewButtonSize; } GUI.color = Color.Lerp(Color.gray, HUXEditorUtils.DefaultColor, 0.5f); switch (state) { case AppBar.AppBarStateEnum.Default: switch (template.Type) { case AppBar.ButtonTypeEnum.Custom: GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; break; case AppBar.ButtonTypeEnum.Adjust: if (useAdjust) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; case AppBar.ButtonTypeEnum.Hide: if (useHide) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; case AppBar.ButtonTypeEnum.Remove: if (useRemove) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; default: break; } break; case AppBar.AppBarStateEnum.Hidden: switch (template.Type) { case AppBar.ButtonTypeEnum.Show: if (useHide) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; default: break; } break; case AppBar.AppBarStateEnum.Manipulation: switch (template.Type) { default: break; case AppBar.ButtonTypeEnum.Done: GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; break; case AppBar.ButtonTypeEnum.Remove: if (useRemove) { GUILayout.Button(template.Text, buttonPreviewStyle); drewButton = true; } break; } break; } GUI.color = HUXEditorUtils.DefaultColor; HUXEditorUtils.SaveChanges(target, serializedObject); return(drewButton); }
private AppBar.ButtonTemplate DrawButtonEditor(AppBar.ButtonTemplate template, ButtonIconProfile profile, ref int numCustomButtons, string arrayName, int templateIndex) { // Set the button's position immediately template.DefaultPosition = 0; if (!template.IsEmpty) { numCustomButtons++; template.DefaultPosition = numCustomButtons; } HUXEditorUtils.BeginSectionBox(template.IsEmpty ? "(Empty)" : template.Name + " (" + template.DefaultPosition + ")", HUXEditorUtils.ObjectColor); template.Type = AppBar.ButtonTypeEnum.Custom; GUI.color = template.IsEmpty ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor; EditorGUILayout.BeginHorizontal(); template.Name = EditorGUILayout.TextField("Button Name", template.Name); if (GUILayout.Button("Clear", EditorStyles.miniButton)) { template.Name = string.Empty; } EditorGUILayout.EndHorizontal(); if (!template.IsEmpty) { if (string.IsNullOrEmpty(template.Text)) { GUI.color = HUXEditorUtils.WarningColor; } template.Text = EditorGUILayout.TextField("Label Text", template.Text); GUI.color = HUXEditorUtils.DefaultColor; string[] keys = profile.GetIconKeys().ToArray(); int selectedIndex = 0; for (int i = 0; i < keys.Length; i++) { if (keys[i].Equals(template.Icon)) { selectedIndex = i; break; } } selectedIndex = EditorGUILayout.Popup("Icon", selectedIndex, keys); template.Icon = keys[selectedIndex]; template.EventTarget = HUXEditorUtils.SceneObjectField <InteractionReceiver>("Interaction Receiver", template.EventTarget); if (template.EventTarget == null) { HUXEditorUtils.WarningMessage("This button will have no effect until you choose an interaction receiver to register it with."); } } // Draw the unity message section /*string propertyName = string.Format("{0}.Array.data[{1}].OnTappedEvent", arrayName, templateIndex); * SerializedProperty buttonEvent = serializedObject.FindProperty(propertyName); * EditorGUILayout.PropertyField(buttonEvent); * if (GUI.changed) { * serializedObject.ApplyModifiedProperties(); * }*/ HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target, serializedObject); return(template); }
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() { HandCoach coach = (HandCoach)target; //DrawDefaultInspector(); HUXEditorUtils.BeginSectionBox("Material settings"); coach.HandMaterial = (Material)EditorGUILayout.ObjectField("Material", coach.HandMaterial, typeof(Material), false); coach.HighlightColor = EditorGUILayout.ColorField("Highlight color", coach.HighlightColor); coach.NormalColor = EditorGUILayout.ColorField("Normal color", coach.NormalColor); coach.TrackedColor = EditorGUILayout.ColorField("Tracked color", coach.TrackedColor); coach.TrackingLostColor = EditorGUILayout.ColorField("Tracking lost color", coach.TrackingLostColor); coach.HighlightColorProperty = HUXEditorUtils.MaterialPropertyName(coach.HighlightColorProperty, coach.HandMaterial, ShaderUtil.ShaderPropertyType.Color, false, "_Color", "Highlight"); coach.TrackingColorProperty = HUXEditorUtils.MaterialPropertyName(coach.TrackingColorProperty, coach.HandMaterial, ShaderUtil.ShaderPropertyType.Color, false, "_Color", "Tracking"); coach.MaterialTransparencyIsFloat = EditorGUILayout.Toggle("Use float property for transparency", coach.MaterialTransparencyIsFloat); if (coach.MaterialTransparencyIsFloat) { coach.MaterialTransparencyProperty = HUXEditorUtils.MaterialPropertyName(coach.MaterialTransparencyProperty, coach.HandMaterial, ShaderUtil.ShaderPropertyType.Range, false, "_Color", "Transparency"); } else { coach.MaterialTransparencyProperty = HUXEditorUtils.MaterialPropertyName(coach.MaterialTransparencyProperty, coach.HandMaterial, ShaderUtil.ShaderPropertyType.Color, false, "_Color", "Transparency"); } coach.Highlight = (HandCoach.HandVisibilityEnum)EditorGUILayout.EnumPopup("Hands to highlight", coach.Highlight); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Tracking settings"); coach.CheckTracking = (HandCoach.HandVisibilityEnum)EditorGUILayout.EnumPopup("Check tracking", coach.CheckTracking); coach.AutoGhostLostTracking = EditorGUILayout.Toggle("Auto-ghost hands when tracking lost", coach.AutoGhostLostTracking); coach.Ghosting = (HandCoach.HandVisibilityEnum)EditorGUILayout.EnumPopup("Ghosting", coach.Ghosting); coach.Tracking = (HandCoach.HandVisibilityEnum)EditorGUILayout.EnumPopup("Tracking", coach.Tracking); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Gesture settings"); coach.Visibility = (HandCoach.HandVisibilityEnum)EditorGUILayout.EnumPopup("Hands to show", coach.Visibility); coach.AutoLowerOnInvisible = EditorGUILayout.Toggle("Auto-lower on invisible", coach.AutoLowerOnInvisible); coach.RightGesture = (HandCoach.HandGestureEnum)EditorGUILayout.EnumPopup("Right gesture", coach.RightGesture); coach.LeftGesture = (HandCoach.HandGestureEnum)EditorGUILayout.EnumPopup("Left gesture", coach.LeftGesture); coach.RightMovement = (HandCoach.HandMovementEnum)EditorGUILayout.EnumPopup("Right movement", coach.RightMovement); coach.LeftMovement = (HandCoach.HandMovementEnum)EditorGUILayout.EnumPopup("Left movement", coach.LeftMovement); coach.RightDirection = (HandCoach.HandDirectionEnum)HUXEditorUtils.EnumCheckboxField <HandCoach.HandDirectionEnum>("Right hand direction", coach.RightDirection, "None", HandCoach.HandDirectionEnum.None); coach.LeftDirection = (HandCoach.HandDirectionEnum)HUXEditorUtils.EnumCheckboxField <HandCoach.HandDirectionEnum>("Left hand direction", coach.LeftDirection, "None", HandCoach.HandDirectionEnum.None); coach.StaticCurve = EditorGUILayout.CurveField("Static movement curve", coach.StaticCurve); coach.DirectionalCurve = EditorGUILayout.CurveField("Directional movement curve", coach.DirectionalCurve); coach.DirectionalTransparencyCurve = EditorGUILayout.CurveField("Directional movement transparency curve", coach.DirectionalTransparencyCurve); coach.PingPongCurve = EditorGUILayout.CurveField("Ping pong movement curve", coach.PingPongCurve); HUXEditorUtils.EndSectionBox(); serializedObject.ApplyModifiedProperties(); HUXEditorUtils.SaveChanges(target); }
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); }
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); }
public override void OnInspectorGUI() { CompoundButtonIcon iconButton = (CompoundButtonIcon)target; iconButton.DisableIcon = EditorGUILayout.Toggle("Disable icon", iconButton.DisableIcon); if (iconButton.DisableIcon) { HUXEditorUtils.SaveChanges(target); return; } profileProp.objectReferenceValue = HUXEditorUtils.DrawProfileField <ButtonIconProfile>(profileProp.objectReferenceValue as ButtonIconProfile); //iconButton.Profile = HUXEditorUtils.DrawProfileField<ButtonIconProfile>(iconButton.Profile); if (iconButton.Profile == null) { HUXEditorUtils.SaveChanges(target); return; } HUXEditorUtils.BeginSectionBox("Icon settings"); if (UnityEditor.Selection.gameObjects.Length == 1) { iconButton.IconRenderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Icon renderer", iconButton.IconRenderer, iconButton.transform); if (iconButton.IconRenderer == null) { HUXEditorUtils.ErrorMessage("You must specify an icon renderer", null); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target); return; } if (iconButton.Profile.IconMaterial == null) { HUXEditorUtils.ErrorMessage("You must specify an icon material in the profile", null); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target); return; } if (iconButton.Profile.IconMesh == null) { HUXEditorUtils.ErrorMessage("You must specify an icon mesh in the profile", null); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target); return; } // Icon profiles provide their own fields for the icon name iconButton.Alpha = EditorGUILayout.Slider("Icon transparency", iconButton.Alpha, 0f, 1f); iconButton.IconName = iconButton.Profile.DrawIconSelectField(iconButton.IconName); } else { EditorGUILayout.LabelField("(This section not supported for multiple objects)", EditorStyles.miniLabel); } HUXEditorUtils.EndSectionBox(); HUXEditorUtils.DrawProfileInspector(iconButton.Profile, iconButton); // Check to see if the icon is valid - if it's not, show the placeholder /*Texture2D icon = iconButton.IconRenderer.sharedMaterial.mainTexture as Texture2D; * if (icon == null || icon == iconButton.IconProfile._IconNotFound_) * { * HUXEditorUtils.WarningMessage( * "Texture '" + iconButton.IconName + "' was not found in the selected profile. A substitute will be displayed until an icon file has been added to the profile.", * "Click to open profile", * ClickToOpen); * }*/ HUXEditorUtils.SaveChanges(iconButton, iconButton.Profile); serializedObject.ApplyModifiedProperties(); }
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); }
public override void OnInspectorGUI() { DrawDefaultInspector(); CompoundButtonAnim acb = (CompoundButtonAnim)target; if (UnityEditor.Selection.gameObjects.Length == 1) { acb.TargetAnimator = HUXEditorUtils.DropDownComponentField <Animator>("Target animator", acb.TargetAnimator, acb.transform); if (acb.TargetAnimator == null) { GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("You must chooes a target animator."); HUXEditorUtils.SaveChanges(target, serializedObject); return; } } else { EditorGUILayout.LabelField("(This section not supported for multiple objects)", EditorStyles.miniLabel); } Animator animator = acb.TargetAnimator; AnimatorControllerParameter[] animParams = null; if (!animator.isInitialized) { HUXEditorUtils.SaveChanges(target, serializedObject); return; } // Validate the AnimButton controls - make sure there's one control for each button state Button.ButtonStateEnum[] buttonStates = (Button.ButtonStateEnum[])System.Enum.GetValues(typeof(Button.ButtonStateEnum)); if (acb.AnimActions == null || acb.AnimActions.Length != buttonStates.Length) { acb.AnimActions = new CompoundButtonAnim.AnimatorControllerAction[buttonStates.Length]; } // Don't allow user to change setup during play mode if (!Application.isPlaying) { // Get the available animation parameters animParams = animator.parameters; for (int i = 0; i < buttonStates.Length; i++) { acb.AnimActions[i].ButtonState = buttonStates[i]; } // Now make sure all animation parameters are found for (int i = 0; i < acb.AnimActions.Length; i++) { if (!string.IsNullOrEmpty(acb.AnimActions[i].ParamName)) { bool invalidParam = true; foreach (AnimatorControllerParameter animParam in animParams) { if (acb.AnimActions[i].ParamName == animParam.name) { // Update the type while we're here invalidParam = false; acb.AnimActions[i].ParamType = animParam.type; break; } } // If we didn't find it, mark it as invalid acb.AnimActions[i].InvalidParam = invalidParam; } } } if (!acb.gameObject.activeInHierarchy) { //GUI.color = HUX.Editor.EditorStyles.ColorWarning; EditorGUILayout.LabelField("(Gameobject must be active to view animation actions)"); HUXEditorUtils.SaveChanges(target, serializedObject); return; } // Draw the editor for all the anim actions HUXEditorUtils.BeginSectionBox("Animation actions"); for (int i = 0; i < acb.AnimActions.Length; i++) { acb.AnimActions[i] = DrawAnimActionEditor(acb.AnimActions[i], animParams); } HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target, serializedObject); }
public override void OnInspectorGUI() { CompoundButtonText textButton = (CompoundButtonText)target; textAreaLabel = new GUIStyle(EditorStyles.textArea); textAreaLabel.fontSize = 32; GUI.color = Color.white; textButton.DisableText = EditorGUILayout.Toggle("Disable text", textButton.DisableText); if (textButton.DisableText) { HUXEditorUtils.SaveChanges(target); return; } textButton.TextProfile = HUXEditorUtils.DrawProfileField <ButtonTextProfile>(textButton.TextProfile); if (textButton.TextProfile == null) { HUXEditorUtils.SaveChanges(target); return; } textButton.TextMesh = HUXEditorUtils.DropDownComponentField <TextMesh>("Text mesh", textButton.TextMesh, textButton.transform); //textButton.TextMesh = (TextMesh)EditorGUILayout.ObjectField("Text mesh", textButton.TextMesh, typeof(TextMesh), true); if (textButton.TextMesh == null) { GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("You must select a text mesh object."); HUXEditorUtils.SaveChanges(target); return; } HUXEditorUtils.BeginSectionBox("Overrides"); EditorGUILayout.BeginHorizontal(); textButton.OverrideFontStyle = EditorGUILayout.Toggle("Font style", textButton.OverrideFontStyle); if (textButton.OverrideFontStyle) { textButton.Style = (FontStyle)EditorGUILayout.EnumPopup(textButton.Style); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); textButton.OverrideAnchor = EditorGUILayout.Toggle("Text anchor", textButton.OverrideAnchor); if (textButton.OverrideAnchor) { textButton.Anchor = (TextAnchor)EditorGUILayout.EnumPopup(textButton.Anchor); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); textButton.OverrideSize = EditorGUILayout.Toggle("Text size", textButton.OverrideSize); if (textButton.OverrideSize) { textButton.Size = EditorGUILayout.IntField(textButton.Size); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); textButton.OverrideOffset = EditorGUILayout.Toggle("Offset", textButton.OverrideOffset); if (textButton.OverrideOffset) { EditorGUILayout.LabelField("(You may now manually adjust the offset of the text)", EditorStyles.miniLabel); } EditorGUILayout.EndHorizontal(); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Button text"); textButton.Text = EditorGUILayout.TextArea(textButton.Text, textAreaLabel); HUXEditorUtils.EndSectionBox(); //textButton.Alpha = EditorGUILayout.Slider("Text transparency", textButton.Alpha, 0f, 1f); HUXEditorUtils.DrawProfileInspector(textButton.TextProfile, textButton); HUXEditorUtils.SaveChanges(target); }
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() { CompoundButton cb = (CompoundButton)target; // Don't perform this check at runtime if (!Application.isPlaying) { // First, check our colliders // Get the components we need for the button to be visible Rigidbody parentRigidBody = cb.GetComponent <Rigidbody>(); Collider parentCollider = cb.GetComponent <Collider>(); // Get all child colliders that AREN'T the parent collider HashSet <Collider> childColliders = new HashSet <Collider>(cb.GetComponentsInChildren <Collider>()); childColliders.Remove(parentCollider); bool foundError = false; EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (parentCollider == null) { if (childColliders.Count == 0) { foundError = true; GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("Error: Button must have at least 1 collider to be visible, preferably on the root transform.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { cb.gameObject.AddComponent <BoxCollider>(); } } else if (parentRigidBody == null) { foundError = true; GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("Error: Button requires a rigidbody if colliders are only present on child transforms.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { Rigidbody rb = cb.gameObject.AddComponent <Rigidbody>(); rb.isKinematic = true; } } else if (!parentRigidBody.isKinematic) { foundError = true; GUI.color = HUXEditorUtils.WarningColor; EditorGUILayout.LabelField("Warning: Button rigid body is not kinematic - this is not recommended.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { parentRigidBody.isKinematic = true; } } } // If our colliders were fine, next check the interaction manager to make sure the button will be visible if (!foundError) { FocusManager fm = GameObject.FindObjectOfType <FocusManager>(); if (fm != null) { if (fm.RaycastLayerMask != (fm.RaycastLayerMask | (1 << cb.gameObject.layer))) { foundError = true; GUI.color = HUXEditorUtils.WarningColor; EditorGUILayout.LabelField("Warning: Button is not on a layer that the focus manager can see. Button will not receive input until either the button's layer or the FocusManager's RaycastLayerMask is changed. (This may be intentional.)", EditorStyles.wordWrappedLabel); if (fm.RaycastLayerMask.value != 0) { if (GUILayout.Button("Fix now")) { // Put the button on the first layer that the layer mask can see for (int i = 0; i < 32; i++) { if (fm.RaycastLayerMask == (fm.RaycastLayerMask | (1 << i))) { cb.gameObject.layer = i; break; } } } } } } else { EditorGUILayout.LabelField("(Couldn't find a focus manager to perform visibility check)", EditorStyles.wordWrappedLabel); } } if (!foundError) { GUI.color = HUXEditorUtils.SuccessColor; EditorGUILayout.LabelField("Button is good to go!", EditorStyles.wordWrappedLabel); } EditorGUILayout.EndVertical(); } GUI.color = HUXEditorUtils.DefaultColor; HUXEditorUtils.BeginSectionBox("Button properties", HUXEditorUtils.DefaultColor); // Draw the filter tag field HUXEditorUtils.DrawFilterTagField(serializedObject, "FilterTag"); cb.RequireGaze = EditorGUILayout.Toggle("Require Gaze", cb.RequireGaze); cb.ButtonState = (Button.ButtonStateEnum)EditorGUILayout.EnumPopup("Button State", cb.ButtonState); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Commonly referenced components", HUXEditorUtils.DefaultColor); cb.MainCollider = HUXEditorUtils.DropDownComponentField <Collider>("Main collider", cb.MainCollider, cb.transform); cb.MainRenderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Main renderer", cb.MainRenderer, cb.transform); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(cb); }
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); }
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); }