protected void DrawClipEditor(ref AudioClip clip, ref float volume, string label) { HUXEditorUtils.BeginSubSectionBox(label); EditorGUILayout.BeginHorizontal(); clip = (AudioClip)EditorGUILayout.ObjectField(clip, typeof(UnityEngine.AudioClip), true); volume = EditorGUILayout.Slider(volume, 0f, 1f); EditorGUILayout.EndHorizontal(); HUXEditorUtils.EndSubSectionBox(); }
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() { 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() { 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); }
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() { 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); }