/// <summary> /// Inspector GUI shown in the Editor window. /// </summary> /// <param name="brushSettings"></param> internal virtual void DrawGUI(BrushSettings brushSettings) { if (PolyGUILayout.HeaderWithDocsLink(PolyGUI.TempContent(ModeSettingsHeader, ""))) { Application.OpenURL(DocsLink); } }
internal static uint BitMaskField(uint value, string[] descriptions, string tooltip) { GUIContent gc = PolyGUI.TempContent("", tooltip); using (new GUILayout.HorizontalScope()) { int l = descriptions.Length; for (int i = 1; i < l; i++) { int s = i - 1; bool toggled = (value & (1u << s)) > 0; gc.text = descriptions[i]; bool newValue = GUILayout.Toggle(toggled, gc, "Button", GUILayout.Width(30)); if (toggled != newValue) { value ^= (1u << s); } } } return(value); }
internal static Gradient GradientField(GUIContent gc, Gradient value) { GUILayout.Label(gc); object out_gradient = EditorGUILayout.GradientField(PolyGUI.TempContent("", gc.tooltip), value, null); return((Gradient)out_gradient); }
public static bool Foldout(bool state, GUIContent content, GUILayoutOption[] options) { if (GUILayout.Button(PolyGUI.TempContent(""), state ? "FoldoutOpen" : "FoldoutClosed", options)) { state = !state; } GUILayout.Label(content, options); return(state); }
internal static Color ColorField(GUIContent gc, Color color) { if (gc != null && !string.IsNullOrEmpty(gc.text)) { GUILayout.Label(gc); } var ret = EditorGUILayout.ColorField(PolyGUI.TempContent("", gc.tooltip), color); return(ret); }
/// <summary> /// Copy/paste of Unity TextAssetInspector, since DrawDefaultInspector doesn't work with TextAssets. /// Not using reflection because this is such a small function that it makes more sense to just c/p /// and avoid the issues of Unity possibly changing names or signatures in the future. /// </summary> private void DrawTextAssetInspector() { if (m_TextStyle == null) { m_TextStyle = "ScriptText"; } bool enabled = GUI.enabled; GUI.enabled = true; TextAsset textAsset = this.target as TextAsset; if (textAsset != null) { string text; if (base.targets.Length > 1) { text = string.Format("{0} Text Assets", base.targets.Length); } else { text = textAsset.ToString(); if (text.Length > 7000) { text = text.Substring(0, 7000) + "...\n\n<...etc...>"; } } Rect rect = GUILayoutUtility.GetRect(PolyGUI.TempContent(text), m_TextStyle); rect.x = 0f; rect.y -= 3f; rect.width = EditorGUIUtility.currentViewWidth - 1; // GUIClip.visibleRect.width + 1f; GUI.Box(rect, text, m_TextStyle); } GUI.enabled = enabled; }
/// <summary> /// Color field control /// </summary> /// <param name="text"></param> /// <param name="mask"></param> /// <returns></returns> internal static ColorMask ColorMaskField(string text, ColorMask mask) { return(ColorMaskField(string.IsNullOrEmpty(text) ? null : PolyGUI.TempContent(text), mask)); }
/// <summary> /// Similar to EditorGUILayoutUtility.Slider, except this allows for values outside of the min/max bounds via the float field. /// </summary> /// <param name="content"></param> /// <param name="value"></param> /// <param name="min"></param> /// <param name="max"></param> /// <returns></returns> internal static float FreeSlider(string content, float value, float min, float max) { return(FreeSlider(PolyGUI.TempContent(content), value, min, max)); }
void DrawBrushSettings() { // Brush preset selector using (new GUILayout.VerticalScope("box")) { // Show the settings header in PolyEditor so that the preset selector can be included in the block. // Can't move preset selector to BrushSettingsEditor because it's a CustomEditor for BrushSettings, // along with other issues. if (PolyGUILayout.HeaderWithDocsLink(PolyGUI.TempContent("Brush Settings"))) { Application.OpenURL(PrefUtility.documentationBrushSettingsLink); } using (new GUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); m_CurrentBrushIndex = EditorGUILayout.Popup(m_CurrentBrushIndex, m_AvailableBrushesStrings, "Popup"); if (EditorGUI.EndChangeCheck()) { if (m_CurrentBrushIndex >= m_AvailableBrushes.Count) { SetBrushSettings(BrushSettingsEditor.AddNew(brushSettings)); } else { SetBrushSettings(m_AvailableBrushes[m_CurrentBrushIndex]); } } if (GUILayout.Button(m_GCSaveBrushSettings, GUILayout.Width(40))) { if (brushSettings != null && brushSettingsAsset != null) { // integer 0, 1 or 2 corresponding to ok, cancel and alt buttons int res = EditorUtility.DisplayDialogComplex("Save Brush Settings", "Overwrite brush preset, or Create a New brush preset? ", "Overwrite", "Create New", "Cancel"); if (res == 0) { brushSettings.CopyTo(brushSettingsAsset); EditorGUIUtility.PingObject(brushSettingsAsset); } else if (res == 1) { BrushSettings dup = BrushSettingsEditor.AddNew(brushSettings); SetBrushSettings(dup); EditorGUIUtility.PingObject(brushSettingsAsset); } } else { Debug.LogWarning("Something went wrong saving brush settings."); } } } EditorGUI.BeginChangeCheck(); brushEditor.OnInspectorGUI(); } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.ObjectField("Shader", shader, typeof(Shader), false); for (int i = 0; i < p_attributes.arraySize; i++) { SerializedProperty attrib = p_attributes.GetArrayElementAtIndex(i); GUI.backgroundColor = i % 2 == 0 ? LIGHT_GRAY : DARK_GRAY; GUILayout.BeginVertical(PolyGUI.BackgroundColorStyle); GUI.backgroundColor = Color.white; SerializedProperty target = attrib.FindPropertyRelative("propertyTarget"); SerializedProperty channel = attrib.FindPropertyRelative("channel"); SerializedProperty index = attrib.FindPropertyRelative("index"); SerializedProperty range = attrib.FindPropertyRelative("range"); SerializedProperty mask = attrib.FindPropertyRelative("mask"); EditorGUILayout.PropertyField(target); EditorGUILayout.PropertyField(channel); EditorGUILayout.IntPopup(index, ComponentIndexUtility.ComponentIndexPopupDescriptions, ComponentIndexUtility.ComponentIndexPopupValues); bool old = EditorGUIUtility.wideMode; EditorGUIUtility.wideMode = true; EditorGUILayout.PropertyField(range); EditorGUIUtility.wideMode = old; EditorGUILayout.IntPopup(mask, AttributeLayout.DefaultMaskDescriptions, AttributeLayout.DefaultMaskValues, PolyGUI.TempContent("Group")); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Delete", EditorStyles.miniButton)) { p_attributes.DeleteArrayElementAtIndex(i); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } if (GUILayout.Button("Add Attribute")) { p_attributes.arraySize++; } serializedObject.ApplyModifiedProperties(); }