public static int MinMaxSlider(Rect rt, string name, ref int minValue, ref int maxValue, int maxLimit, Color color) { if (isEnable == false) { return(0); } Color col = GUI.color; GUI.color = color; GUITools.Box(rt, ""); GUI.color = Color.white; if ((minValue == 0) && (maxValue <= 0)) { maxValue = maxLimit; } rt.Set(rt.x + 5, rt.y + 5, rt.width - 10, 20); int ret = GUITools.MinMaxSlider(rt, name, ref minValue, ref maxValue, 0, maxLimit, 140); GUI.color = col; return(ret); }
static void DrawFieldList(float x, float y, float w, float h, object data, ref Vector2 scroll, List <FieldInfo> fiList) { if (data == null) { return; } Color color = GUI.color; Rect rt = new Rect(x, y, w, h); GUITools.Box(rt, data.GetType().ToString()); float labelSize = 250; float title = 20; float hh = 30; x += 5; y += (5 + title); w -= 10; h -= (10 + title); rt.Set(x, y, w, h); float height = rt.height; float length = GetFieldSubCount(data) * hh; Rect rt2 = new Rect(0, 0, 1, 1); if (height < length) { height = length; rt2.Set(x, y, w - 20, height); } else { rt2.Set(x, y, w, height); } scroll = GUI.BeginScrollView(rt, scroll, rt2); //GUI.enabled = false; rt.Set(x + 5, y, rt2.width - 10, hh); DrawFieldSubList(rt.x, rt.y, rt.width, rt.height, "", ref data, labelSize, fiList); //GUI.enabled = true; GUI.EndScrollView(); GUI.color = color; }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { SerializedProperty clipsProp = prop.FindPropertyRelative("clips"); SerializedProperty is2D = prop.FindPropertyRelative("is2D"); SerializedProperty oneShot = prop.FindPropertyRelative("oneShot"); if (string.IsNullOrEmpty(label.text)) { label = new GUIContent("Clip"); } pos.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(pos, label, GUITools.boldLabel); DrawToolbar(pos.x + pos.width - GUITools.iconButtonWidth * 5, pos.y, prop, oneShot, is2D); GUITools.Box(new Rect(pos.x, pos.y, pos.width, CalculateHeight(clipsProp, is2D, prop.isExpanded) - EditorGUIUtility.singleLineHeight * .25f), GUITools.shade); pos.y += GUITools.singleLineHeight; pos.x += GUITools.iconButtonWidth * .5f; pos.width -= GUITools.iconButtonWidth * .5f; EditorGUI.PropertyField(pos, clipsProp, true); pos.y += EditorGUI.GetPropertyHeight(clipsProp, true); DrawProp(prop, ref pos, "volume"); DrawProp(prop, ref pos, "pitchRange"); if (!is2D.boolValue) { DrawProp(prop, ref pos, "minMaxDistance"); } if (prop.isExpanded) { if (!is2D.boolValue) { DrawProp(prop, ref pos, "spread"); DrawProp(prop, ref pos, "doppler"); } DrawProp(prop, ref pos, "priority"); DrawProp(prop, ref pos, "stereoPan"); } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { GUITools.Box(new Rect(pos.x, pos.y, pos.width, EditorGUIUtility.singleLineHeight * 4.1f), GUITools.shade); pos.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(pos, label, GUITools.boldLabel); pos.y += EditorGUIUtility.singleLineHeight; pos.x += GUITools.iconButtonWidth * .5f; pos.width -= GUITools.iconButtonWidth * .5f; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("particle"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("size"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("playbackSpeed"), true); }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { EditorGUI.BeginProperty(pos, label, prop); GUITools.Box(new Rect(pos.x, pos.y, pos.width, EditorGUIUtility.singleLineHeight * 3 + GUITools.singleLineHeight), GUITools.shade); pos.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(pos, label, GUITools.boldLabel); pos.y += EditorGUIUtility.singleLineHeight; float w = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("position"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("rotation"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("scale"), true); EditorGUIUtility.labelWidth = w; EditorGUI.EndProperty(); }
void DrawGroupSceneGUI(SerializedProperty subLocsListProp) { float screenW = SceneView.lastActiveSceneView.position.width; float screenH = SceneView.lastActiveSceneView.position.height; for (int i = 0; i < subLocsListProp.arraySize; i++) { SerializedProperty s = subLocsListProp.GetArrayElementAtIndex(i); bool selected = s.FindPropertyRelative("selected").boolValue; bool hovered = s.FindPropertyRelative("hovered").boolValue; if (!selected && !hovered) { continue; } SerializedProperty posProp = s.FindPropertyRelative("position"); Vector3 pos = posProp.vector3Value; Vector3 screenPos = SceneView.lastActiveSceneView.camera.WorldToViewportPoint(pos); Handles.BeginGUI(); GUIContent lbl = new GUIContent(s.FindPropertyRelative("name").stringValue); float w = GUITools.label.CalcSize(lbl).x; Rect labelRect = new Rect(screenPos.x * screenW - w * .5f, (1 - screenPos.y) * screenH - EditorGUIUtility.singleLineHeight, w, EditorGUIUtility.singleLineHeight); GUITools.Box(labelRect, hovered ? GUITools.white : colorSolid); GUI.Label(labelRect, lbl); Handles.EndGUI(); if (selected || hovered) { posProp.vector3Value = Handles.PositionHandle(pos, Quaternion.Euler(0, s.FindPropertyRelative("rotation").floatValue, 0)); } } LocationPainter.OnSceneGUI(subLocsListProp, GetHashCode()); }
public static bool IntSlider(Rect rt, string name, ref int value, int maxLimit, Color color) { if (isEnable == false) { return(false); } Color col = GUI.color; GUI.color = color; GUITools.Box(rt, ""); GUI.color = Color.white; rt.Set(rt.x + 5, rt.y + 5, rt.width - 10, 20); int ret = value; value = GUITools.IntSlider(rt, name, ret, 0, maxLimit, 140); GUI.color = col; return((value != ret)?true:false); }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { SerializedProperty useAlias = prop.FindPropertyRelative("useAlias"); GUITools.Box(new Rect(pos.x, pos.y, pos.width, CalcHeight(useAlias)), new Color32(0, 0, 0, 32)); pos.height = GUITools.singleLineHeight; GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel); GUITools.DrawIconToggle(useAlias, new GUIContent("A", "Use Alias"), pos.x + (pos.width - GUITools.iconButtonWidth), pos.y); pos.y += GUITools.singleLineHeight; if (useAlias.boolValue) { SerializedProperty aliasProp = prop.FindPropertyRelative("alias"); DrawKeySelect(pos, aliasProp); GUI.enabled = !string.IsNullOrEmpty(aliasProp.stringValue); if (GUITools.IconButton(pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, new GUIContent("G", "Go To Scene / Location"), GUITools.white)) { LocationKey key = LocationAliases.GetLocationKey(aliasProp.stringValue); if (key != null) { LocationKeyDrawer.FastTravelToLocation(key.scene, key.name); } } GUI.enabled = true; } else { EditorGUI.PropertyField(pos, prop.FindPropertyRelative("key"), true); } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { SerializedProperty clipsProp = prop.FindPropertyRelative("clips"); SerializedProperty is2D = prop.FindPropertyRelative("is2D"); SerializedProperty showAdvanced = prop.FindPropertyRelative("showAdvanced"); pos.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(pos, label, GUITools.boldLabel); float h = CalculateHeight(clipsProp, is2D, showAdvanced); GUITools.Box(new Rect(pos.x, pos.y, pos.width, h + EditorGUIUtility.singleLineHeight * .1f), GUITools.shade); pos.y += GUITools.singleLineHeight; pos.x += GUITools.iconButtonWidth; pos.width -= GUITools.iconButtonWidth; EditorGUI.PropertyField(pos, clipsProp, true); pos.y += EditorGUI.GetPropertyHeight(clipsProp, true); pos.height = GUITools.singleLineHeight; SerializedProperty oneShot = prop.FindPropertyRelative("oneShot"); float x = pos.x; if (!oneShot.boolValue) { GUITools.DrawToggleButton(prop.FindPropertyRelative("loop"), unloopedContent, x, pos.y, GUITools.blue, GUITools.white); x += GUITools.iconButtonWidth; } GUITools.DrawToggleButton(oneShot, oneShotContent, x, pos.y, GUITools.blue, GUITools.white); x += GUITools.iconButtonWidth; GUITools.DrawToggleButton(is2D, spatialContent, x, pos.y, GUITools.white, GUITools.blue); x += GUITools.iconButtonWidth; if (!is2D.boolValue) { GUITools.DrawToggleButton(prop.FindPropertyRelative("useLinearRolloff"), linearRolloffContent, x, pos.y, GUITools.blue, GUITools.white); x += GUITools.iconButtonWidth; } GUITools.DrawToggleButton(showAdvanced, advancedSettingsContent, x, pos.y, GUITools.blue, GUITools.white); pos.y += GUITools.singleLineHeight; GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("volume"), volumeContent, GUITools.white); pos.y += GUITools.singleLineHeight; GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("pitchRange"), pitchRangeContent, GUITools.white); pos.y += GUITools.singleLineHeight; if (!is2D.boolValue) { GUITools.DrawIconPrefixedField(pos.x, pos.y, pos.width, pos.height, prop.FindPropertyRelative("minMaxDistance"), minMaxDistanceContent, GUITools.white); pos.y += GUITools.singleLineHeight; } if (showAdvanced.boolValue) { pos.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(pos, "Advanced Settings:", GUITools.boldLabel); pos.y += EditorGUIUtility.singleLineHeight; if (!is2D.boolValue) { EditorGUI.PropertyField(pos, prop.FindPropertyRelative("spread"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("doppler"), true); pos.y += EditorGUIUtility.singleLineHeight; } EditorGUI.PropertyField(pos, prop.FindPropertyRelative("priority"), true); pos.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(pos, prop.FindPropertyRelative("stereoPan"), true); } }
public static void DrawDataList(float x, float y, float w, float h, string name, object obj, ref Vector2 scroll, ref int index, ref int count, out bool isFocus, bool flush = false) { isFocus = false; IList list = obj as IList; if (list == null) { return; } Color color = GUI.color; Rect rt = new Rect(x, y, w, h); GUITools.Box(rt, name); float title = 20; float hh = 30; x += 5; y += (5 + title); w -= 10; h -= (10 + title); rt.Set(x, y, w, h - 4); Rect rt2 = new Rect(); float height = rt.height; float length = list.Count * hh; if (height < length) { height = length; rt2.Set(x, y, w - 20, height); } else { rt2.Set(x, y, w, height); } count = list.Count; if (index > (count - 1)) { index = (count - 1); } if (index < 0) { index = 0; } if (flush == true) { float t = y + index * hh; float b = t + hh; float t1 = rt.y + scroll.y; if (t < t1) { scroll.y -= (t1 - t); } float b2 = rt.y + rt.height + scroll.y; if (b > b2) { scroll.y += (b - b2); } } scroll = GUI.BeginScrollView(rt, scroll, rt2); FieldInfo fi; for (int i = 0; i < count; i++) { if (i == index) { GUI.color = Color.yellow; } else { GUI.color = Color.white; } string str = "(" + i + ") ID : "; if (list[i] != null) { if ((fi = list[i].GetType().GetField("_ID")) != null) { str += fi.GetValue(list[i]); } else { str += i; } } else { str += "null"; } rt.Set(x, y + i * hh, rt2.width, hh); if (GUI.Button(rt, str)) { GUI.FocusControl(str); isFocus = true; index = i; } } GUI.EndScrollView(); GUI.color = color; }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { prop = prop.FindPropertyRelative(NeatArrayAttributeDrawer.listName); GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel); if (GUITools.IconButton(pos.x + pos.width - GUITools.iconButtonWidth, pos.y, new GUIContent("", "Unselect All"), GUITools.red)) { for (int i = 0; i < prop.arraySize; i++) { prop.GetArrayElementAtIndex(i).FindPropertyRelative("selected").boolValue = false; } } int indexToDelete = -1; float fieldsY = pos.y + GUITools.singleLineHeight; Rect fieldRect = new Rect( pos.x + GUITools.iconButtonWidth + GUITools.toolbarDividerSize, fieldsY, pos.width - (GUITools.iconButtonWidth * 3 + GUITools.toolbarDividerSize * 2), EditorGUIUtility.singleLineHeight ); Rect colorAreaRect = new Rect( pos.x + GUITools.iconButtonWidth, fieldsY, pos.width - (GUITools.iconButtonWidth * 3), GUITools.singleLineHeight ); Rect hoverAreaRect = new Rect(pos.x, fieldsY, pos.width, GUITools.singleLineHeight); float selectX = pos.x + pos.width - GUITools.iconButtonWidth; float rotateX = selectX - GUITools.iconButtonWidth; Rect rotateRect = new Rect(rotateX, fieldsY, GUITools.iconButtonWidth, GUITools.singleLineHeight); bool focus = false; Event e = Event.current; Vector2 mousePos = e.mousePosition; if (isRotating) { if (e.type == EventType.MouseUp) { isRotating = false; rotateProp = null; } else if (e.type == EventType.MouseDrag) { SerializedProperty rotationProp = rotateProp.FindPropertyRelative("rotation"); rotationProp.floatValue = rotationProp.floatValue + e.delta.x; } } else { if (!LocationPainter.drawing) { if ((EventType.KeyUp == e.type || EventType.KeyDown == e.type) && KeyCode.F == e.keyCode) { focus = EventType.KeyUp == e.type; e.Use(); } } } for (int i = 0; i < prop.arraySize; i++) { if (GUITools.IconButton(pos.x, fieldsY, BuiltInIcons.GetIcon("Toolbar Minus", "Delete Element"), GUITools.red)) { indexToDelete = i; } SerializedProperty p = prop.GetArrayElementAtIndex(i); SerializedProperty hovered = p.FindPropertyRelative("hovered"); if (!isRotating) { hovered.boolValue = false; if (hoverAreaRect.Contains(mousePos)) { hovered.boolValue = true; if (focus) { SceneView.lastActiveSceneView.Frame(new Bounds(p.FindPropertyRelative("position").vector3Value, Vector3.one * 3), false); } } } if (hovered.boolValue) { GUITools.Box(colorAreaRect, GUITools.blue); } else { if (p.FindPropertyRelative("isError").boolValue) { GUITools.Box(colorAreaRect, GUITools.red); } } SerializedProperty nameProp = p.FindPropertyRelative("name"); if (string.IsNullOrEmpty(nameProp.stringValue)) { nameProp.stringValue = "SubLcoation_" + i.ToString(); } EditorGUI.PropertyField(fieldRect, nameProp, GUITools.noContent, true); GUITools.DrawIconToggle(p.FindPropertyRelative("selected"), new GUIContent("", "Select For Movement"), selectX, fieldsY); if (!isRotating) { if (Event.current.type == EventType.MouseDown) { if (rotateRect.Contains(mousePos)) { hovered.boolValue = true; rotateProp = p; isRotating = true; } } } GUITools.DrawIconToggle(isRotating && hovered.boolValue, rotateGUI, rotateX, fieldsY); fieldsY += GUITools.singleLineHeight; fieldRect.y = fieldsY; colorAreaRect.y = fieldsY; hoverAreaRect.y = fieldsY; rotateRect.y = fieldsY; } if (indexToDelete != -1) { prop.DeleteArrayElementAtIndex(indexToDelete); } }