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() { 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() { 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() { 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() { 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); }