public virtual void DrawInspector() { eventModule.Update(Event.current); }
void ObjectPropertiesUI(PropertyBinder[] binders, LevelSegment.ObjectProperty[] properties) { input.Update(); for (int i = 0; i < binders.Length; i++) { LevelSegment.ObjectProperty property = properties[binders[i].index]; if (selectedProperties.Contains(binders[i].index)) { GUI.backgroundColor = ForeverPrefs.highlightColor; GUI.contentColor = ForeverPrefs.highlightContentColor; } else { if (property.extrusionSettings.ignore) { GUI.backgroundColor = Color.gray; } else { GUI.backgroundColor = DreamteckEditorGUI.lightColor; } GUI.contentColor = new Color(1f, 1f, 1f, 0.8f); } GUILayout.BeginVertical(boxStyle); EditorGUILayout.LabelField(i + " " + binders[i].name); GUILayout.EndVertical(); Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.width -= 30; if (lastRect.Contains(Event.current.mousePosition) && input.mouseLeft) { if (Event.current.shift) { if (selectedProperties.Count == 0) { selectedProperties.Add(binders[i].index); } else { if (i < selectedProperties[0]) { for (int n = selectedProperties[0] - 1; n >= i; n--) { if (!selectedProperties.Contains(binders[n].index)) { selectedProperties.Add(binders[n].index); } } } else { for (int n = selectedProperties[0] + 1; n <= i; n++) { if (!selectedProperties.Contains(binders[n].index)) { selectedProperties.Add(binders[n].index); } } } } } else { if (Event.current.control) { if (!selectedProperties.Contains(binders[i].index)) { selectedProperties.Add(binders[i].index); } } else { selectedProperties.Clear(); selectedProperties.Add(binders[i].index); } } Repaint(); if (propertyWindow != null) { propertyWindow.Repaint(); } SceneView.RepaintAll(); } lastRect.width += 30; } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; }
public void DrawEditor() { input.Update(); if (!guiInitialized) { defaultBoxStyle = new GUIStyle(GUI.skin.box); defaultBoxStyle.normal.background = DreamteckEditorGUI.blankImage; defaultBoxStyle.margin = new RectOffset(0, 0, 0, 0); defaultButtonStyle = new GUIStyle(GUI.skin.button); defaultButtonStyle.normal.background = buttonNormal; defaultButtonStyle.normal.textColor = DreamteckEditorGUI.iconColor; defaultButtonStyle.hover.background = buttonHover; defaultButtonStyle.hover.textColor = DreamteckEditorGUI.highlightContentColor; defaultButtonStyle.margin = new RectOffset(2, 2, 2, 2); thumbnailLabel = new GUIStyle(GUI.skin.label); thumbnailLabel.normal.textColor = DreamteckEditorGUI.lightColor; thumbnailLabel.fontSize = 10; thumbnailLabel.alignment = TextAnchor.MiddleCenter; headerToggle = new GUIStyle(GUI.skin.toggle); headerToggle.normal.textColor = Color.white; guiInitialized = true; } if (sequenceAddress.Count > 0) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("<", GUILayout.Width(35))) { sequenceAddress.RemoveAt(sequenceAddress.Count - 1); } GUIContent content = new GUIContent(undoObject.name); float min = 0f, max = 0f; GUI.skin.label.CalcMinMaxWidth(content, out min, out max); GUILayout.Label(undoObject.name, GUILayout.Width(min)); for (int i = 0; i < sequenceAddress.Count; i++) { content = new GUIContent("/ " + sequenceAddress[i].name); GUI.skin.label.CalcMinMaxWidth(content, out min, out max); GUILayout.Label(content, GUILayout.Width(min)); } EditorGUILayout.EndHorizontal(); } scroll = GUILayout.BeginScrollView(scroll, GUILayout.Width(viewRect.width), GUILayout.Height(viewRect.height)); if (sequenceAddress.Count == 0) { for (int i = 0; i < sequences.Length; i++) { SequenceUI(sequences[i]); } if (GUILayout.Button("Add Sequence", GUILayout.Width(100), GUILayout.Height(50))) { SegmentSequence[] newSequence = new SegmentSequence[sequences.Length + 1]; sequences.CopyTo(newSequence, 0); newSequence[newSequence.Length - 1] = new SegmentSequence(); sequences = newSequence; if (onApplySequences != null) { onApplySequences(sequences); } } } else { SequenceUI(sequenceAddress[sequenceAddress.Count - 1]); } GUILayout.EndScrollView(); if (changeDefinition != null && !changeDefinition.nested) { EditorGUI.DrawRect(segmentPanelRect, Color.white); GUILayout.BeginArea(segmentPanelRect); GameObject last = changeDefinition.prefab; last = (GameObject)EditorGUILayout.ObjectField(last, typeof(GameObject), false); if (last != changeDefinition.prefab) { if (onWillChange != null) { onWillChange(); } changeDefinition.prefab = last; changed = true; } GUILayout.EndArea(); if (input.mouseLeftDown && !segmentPanelRect.Contains(Event.current.mousePosition)) { changeDefinition = null; } else if (input.mouseLeftDown) { input.Use(); } } if (dragIndex >= 0) { changed = true; if (input.mouseLeftUp) { dragIndex = -1; segmentArray = null; } else { GUI.color = new Color(1f, 1f, 1f, 0.75f); float dragSize = thumbnailSize * 0.75f; DrawDefinition(new Rect(Event.current.mousePosition.x - dragSize * 0.5f + dragOffset.x, Event.current.mousePosition.y - dragSize * 0.5f + dragOffset.y, dragSize, dragSize), editSequence.segments[dragIndex]); GUI.color = Color.white; if (dragOffset.magnitude > 0.05f) { dragOffset = Vector2.Lerp(dragOffset, Vector2.zero, 0.1f); changed = true; } } } }