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() { CompoundButtonMesh meshButton = (CompoundButtonMesh)target; GUI.color = HUXEditorUtils.DefaultColor; meshButton.Profile = HUXEditorUtils.DrawProfileField <ButtonMeshProfile>(meshButton.Profile); if (meshButton.Profile == null) { HUXEditorUtils.SaveChanges(target); return; } HUXEditorUtils.BeginSectionBox("Target objects"); meshButton.TargetTransform = HUXEditorUtils.DropDownComponentField <Transform> ("Transform", meshButton.TargetTransform, meshButton.transform); if (meshButton.TargetTransform != null && meshButton.TargetTransform == meshButton.transform) { HUXEditorUtils.WarningMessage("Button may behave strangely if scale & offset is applied to transform root. Consider choosing a child transform."); } else if (meshButton.TargetTransform != null) { // Check to see if offset & scale match any of the button defaults bool foundCloseState = false; foreach (CompoundButtonMesh.MeshButtonDatum datum in meshButton.Profile.ButtonStates) { if (meshButton.TargetTransform.localPosition == datum.Offset && meshButton.TargetTransform.localScale == datum.Scale) { foundCloseState = true; break; } } if (!foundCloseState) { HUXEditorUtils.WarningMessage("Transform doesn't match the scale / offset of any button states. Button may appear different at runtime."); } } GUI.color = HUXEditorUtils.DefaultColor; meshButton.Renderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Mesh Renderer", meshButton.Renderer, meshButton.transform); //meshButton.MeshFilter = HUXEditorUtils.DropDownComponentField<MeshFilter>("Mesh Filter", meshButton.MeshFilter, meshButton.transform); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Target material properties", (meshButton.Renderer == null ? HUXEditorUtils.DisabledColor : HUXEditorUtils.DefaultColor)); if (meshButton.Renderer == null) { HUXEditorUtils.DrawSubtleMiniLabel("(No renderer specified)"); } else { meshButton.Profile.ColorPropertyName = HUXEditorUtils.MaterialPropertyName( meshButton.Profile.ColorPropertyName, meshButton.Renderer.sharedMaterial, ShaderUtil.ShaderPropertyType.Color); meshButton.Profile.ValuePropertyName = HUXEditorUtils.MaterialPropertyName( meshButton.Profile.ValuePropertyName, meshButton.Renderer.sharedMaterial, ShaderUtil.ShaderPropertyType.Float); } HUXEditorUtils.EndSectionBox(); // Draw the profile HUXEditorUtils.DrawProfileInspector(meshButton.Profile, meshButton); HUXEditorUtils.SaveChanges(target, meshButton.Profile); }
public override void OnInspectorGUI() { 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() { 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); }