void OnGUI() { Rect rect = new Rect(0, 0, position.width, position.height); Rect toolbarRect = new Rect(rect.x, rect.y, position.width, TOOLBAR_HEIGHT); EditorGUI.LabelField(toolbarRect, GUIContent.none, EditorStyles.toolbar); DrawToolbar(toolbarRect); Rect dataListRect = new Rect(rect.x + LINE_THINKNESS, rect.y + TOOLBAR_HEIGHT + LINE_THINKNESS, DATA_LIST_WIDTH - LINE_THINKNESS * 2, rect.height - TOOLBAR_HEIGHT - LINE_THINKNESS * 2); dataListView.OnGUI(dataListRect); Rect skeletonRect = new Rect(dataListRect.x + dataListRect.width, dataListRect.y, (rect.width - dataListRect.width) * 0.4f, dataListRect.height); EGUI.DrawAreaLine(skeletonRect, Color.black); DrawSkeleton(skeletonRect); Rect partRect = new Rect(skeletonRect.x + skeletonRect.width, dataListRect.y, (rect.width - dataListRect.width) * 0.6f, dataListRect.height); EGUI.DrawAreaLine(partRect, Color.black); DrawParts(partRect); if (GUI.changed && currentCreatorData != null) { EditorUtility.SetDirty(currentCreatorData); } }
private void OnGUI() { if (searchField == null) { searchField = new SearchField(); searchField.autoSetFocusOnFindCommand = true; } Rect toolbarRect = new Rect(0, 0, position.width, TOOLBAR_HEIGHT); DrawToolbar(toolbarRect); Rect tabRect = toolbarRect; tabRect.y += tabRect.height; tabRect.height = TOOLBAR_BTN_HEIGHT; toolbarSelectedIndex = GUI.Toolbar(tabRect, toolbarSelectedIndex, toolbarContents); Rect contentRect = new Rect(tabRect.x + 1, tabRect.y + tabRect.height + 1, position.width - 2, position.height - tabRect.y - tabRect.height - 2); EGUI.DrawAreaLine(contentRect, Color.black); tabViewers[toolbarSelectedIndex].OnGUI(contentRect); if (GUI.changed) { EditorUtility.SetDirty(genConfig); } }
void OnGUI() { if (fontConfigListView == null) { fontConfigListView = new EGUIListView <BitmapFontConfig>(); fontConfigListView.AddItems(fontConfigs.ToArray()); fontConfigListView.OnSelectedChange = (index) => { SelectedChanged(index); }; } Rect toolbarRect = new Rect(0, 0, position.width, TOOLBAR_HEIGHT); DrawToolbar(toolbarRect); Rect listViewRect = new Rect(0, TOOLBAR_HEIGHT, listViewWidth, position.height - TOOLBAR_HEIGHT); DrawListView(listViewRect); EGUI.DrawAreaLine(listViewRect, Color.grey); Rect listViewDragRect = new Rect(listViewRect.x + listViewRect.width, listViewRect.y, LISTVIEW_DRAG_WIDTH, listViewRect.height); DrawListViewDrag(listViewDragRect); EGUI.DrawAreaLine(listViewDragRect, Color.grey); Rect contentRect = new Rect(listViewDragRect.x + listViewDragRect.width, listViewRect.y, position.width - listViewDragRect.x - listViewDragRect.width, listViewRect.height); DrawContent(contentRect); EGUI.DrawAreaLine(contentRect, Color.grey); }
private void DrawProperty(Rect propertyRect) { EGUI.DrawAreaLine(propertyRect, Color.gray); LineSetting setting = LineSetting.Setting; Rect titleRect = new Rect(propertyRect.x, propertyRect.y, propertyRect.width, TRACK_TITLE_HEIGHT); EditorGUI.LabelField(titleRect, "Property", EditorStyles.toolbar); if (Data == null) { return; } Rect contentRect = new Rect(propertyRect.x, propertyRect.y + TRACK_TITLE_HEIGHT, propertyRect.width, propertyRect.height - TRACK_TITLE_HEIGHT); GUILayout.BeginArea(contentRect); { Data.TimeLength = EditorGUILayout.FloatField("Time Length", Data.TimeLength); EditorGUILayout.Space(); if (selectedTrackIndex >= 0) { trackDrawers[selectedTrackIndex].OnDrawProperty(contentRect); } } GUILayout.EndArea(); }
private void DrawTrackline(Rect lineRect) { LineSetting setting = LineSetting.Setting; using (new GUI.ClipScope(lineRect)) { int startY = Mathf.FloorToInt(setting.ScrollPosY / setting.TracklineHeight); int endY = Mathf.CeilToInt((setting.ScrollPosY + lineRect.height) / setting.TracklineHeight); float maxWidth = Data.TimeLength * setting.WidthForSecond; for (int i = startY; i < endY; ++i) { float y = setting.TracklineHeight * i - setting.ScrollPosY; if (i >= trackDrawers.Count) { break; } Rect tRect = new Rect(0, y, lineRect.width, setting.TracklineHeight); tRect.width = Mathf.Min(lineRect.width, maxWidth - setting.ScrollPosX); if (selectedTrackIndex == i) { EGUI.DrawAreaLine(tRect, Color.green); } trackDrawers[i].OnDrawGUI(tRect); } } }
private void DrawLine(Rect lineRect) { EGUI.DrawAreaLine(lineRect, Color.gray); Rect rulerRect = new Rect(lineRect.x, lineRect.y, lineRect.width, LINE_RULER_HEIGHT); EditorGUI.LabelField(rulerRect, GUIContent.none, EditorStyles.toolbar); DrawLineRuler(rulerRect); Rect gridRect = new Rect(lineRect.x, lineRect.y + LINE_RULER_HEIGHT, lineRect.width, lineRect.height - LINE_RULER_HEIGHT); DrawLineGrid(gridRect); if (Data != null) { DrawTrackline(gridRect); LineSetting setting = LineSetting.Setting; using (new GUILayout.AreaScope(gridRect)) { using (var scop = new UnityEditor.EditorGUILayout.ScrollViewScope(setting.ScrollPos)) { float scrollWith = Mathf.Max(Data.TimeLength * setting.WidthForSecond, gridRect.width); float scrollHeight = Mathf.Max(Data.Tracks.Count * setting.TracklineHeight, gridRect.height); GUILayout.Label("", GUILayout.Width(scrollWith), GUILayout.Height(scrollHeight - 20)); setting.ScrollPos = scop.scrollPosition; } } } }
private void DrawAddressData(Rect contentRect, PackerAssetData assetData) { EGUI.DrawAreaLine(contentRect, Color.black); Rect pingBtnRect = new Rect(contentRect.x + contentRect.width - contentRect.height * 2, contentRect.y, contentRect.height * 2, contentRect.height); if (GUI.Button(pingBtnRect, "Ping")) { SelectionUtility.PingObject(assetData.Path); } Rect ValueRect = new Rect(contentRect.x, contentRect.y, contentRect.width - contentRect.height * 2, contentRect.height); Rect drawRect = new Rect(ValueRect.x, ValueRect.y, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "path", assetData.Path); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x, ValueRect.y + drawRect.height, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "address", assetData.Address); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x + ValueRect.width * 0.5f, ValueRect.y, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "labels", string.Join(",", assetData.Labels)); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x + ValueRect.width * 0.5f, ValueRect.y + drawRect.height, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { } EGUI.EndLableWidth(); //if (Window.IsAddressRepeated(assetData.Address, out List<PackerBundleData> datas)) //{ // if (GUI.Button(drawRect,addressRepeatContent)) // { // AssetAddressRepeatPopupContent content = new AssetAddressRepeatPopupContent() // { // RepeatAddressDatas = datas.ToArray(), // }; // PopupWindow.Show(drawRect, content); // } //} }
private void OnGUI() { if (treeView == null) { InitTreeView(); } DrawToolbar(); EditorGUILayout.BeginHorizontal(); { var newSelectedAsset = EditorGUILayout.ObjectField("Selected Asset", selectedAsset, typeof(UnityObject), false); if (newSelectedAsset != selectedAsset && isAutoRefresh) { RefreshTreeView(); } if (!isAutoRefresh) { if (GUILayout.Button("Search ...", GUILayout.Width(80))) { RefreshTreeView(); } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); EGUI.DrawAreaLine(rect, Color.black); Rect toolbarRect = new Rect(rect.x, rect.y, rect.width, 30); int selectedIndex = GUI.Toolbar(toolbarRect, toolbarSelectedIndex, toolbarContents); if (selectedIndex != toolbarSelectedIndex) { toolbarSelectedIndex = selectedIndex; RefreshTreeView(); } Rect treeViewRect = new Rect(rect.x, rect.y + toolbarRect.height, rect.width, rect.height - toolbarRect.height); treeView.OnGUI(treeViewRect); }
private void OnGUI() { m_ToolbarRect = new Rect(0, 0, position.width, TOOLBAR_HEIGHT); DrawToolbar(m_ToolbarRect); if (m_TrackDragLine == null) { m_TrackDragRect = new Rect(MIN_TRACK_WIDTH, m_ToolbarRect.y + m_ToolbarRect.height, DRAG_LINE_SIZE, position.height - m_ToolbarRect.y - m_ToolbarRect.height); m_TrackDragLine = new EGUIDragLine(this, EGUIDirection.Vertical); } if (m_PropertyDragLine == null) { m_PropertyDragRect = new Rect(0, position.height - MIN_PROPERTY_HEIGHT - DRAG_LINE_SIZE, position.width, DRAG_LINE_SIZE); m_PropertyDragLine = new EGUIDragLine(this, EGUIDirection.Horizontal); } m_TrackDragRect = m_TrackDragLine.OnGUI(m_TrackDragRect); if (m_TrackDragRect.x > MAX_TRACK_WIDTH) { m_TrackDragRect.x = MAX_TRACK_WIDTH; } else if (m_TrackDragRect.x < MIN_TRACK_WIDTH) { m_TrackDragRect.x = MIN_TRACK_WIDTH; } m_PropertyDragRect = m_PropertyDragLine.OnGUI(m_PropertyDragRect); if (m_PropertyDragRect.y < position.height - MAX_PROPERTY_HEIGHT - DRAG_LINE_SIZE) { m_PropertyDragRect.y = position.height - MAX_PROPERTY_HEIGHT - DRAG_LINE_SIZE; } else if (m_PropertyDragRect.y > position.height - MIN_PROPERTY_HEIGHT - DRAG_LINE_SIZE) { m_PropertyDragRect.y = position.height - MIN_PROPERTY_HEIGHT - DRAG_LINE_SIZE; } float trackRectX = 0.0f; float trackRectY = m_ToolbarRect.y + m_ToolbarRect.height; float trackRectWidth = m_TrackDragRect.x; float trackRectHeight = m_PropertyDragRect.y - TOOLBAR_HEIGHT; m_TrackRect = new Rect(trackRectX, trackRectY, trackRectWidth, trackRectHeight); m_TrackAreaDrawer.OnGUI(m_TrackRect); float trackPropertyRectX = trackRectX; float trackPropertyRectY = m_PropertyDragRect.y + m_PropertyDragRect.height; float trackPropertyRectWidth = trackRectWidth; float trackPropertyRectHeight = position.y + position.height - m_PropertyDragRect.y - m_PropertyDragRect.height; m_TrackPropertyRect = new Rect(trackPropertyRectX, trackPropertyRectY, trackPropertyRectWidth, trackPropertyRectHeight); m_TrackPropertyAreaDrawer.OnGUI(m_TrackPropertyRect); float actionPropertyRectX = m_TrackDragRect.x + m_TrackDragRect.width; float actionPropertyRectY = trackPropertyRectY; float actionPropertyRectWidth = position.width - m_TrackDragRect.x - m_TrackDragRect.width; float actionPropertyRectHeight = trackPropertyRectHeight; m_ActionPropertyRect = new Rect(actionPropertyRectX, actionPropertyRectY, actionPropertyRectWidth, actionPropertyRectHeight); EGUI.DrawAreaLine(m_ActionPropertyRect, Color.blue); float actionRectX = actionPropertyRectX; float actionRectY = trackRectY; float actionRectWidth = actionPropertyRectWidth; float actionRectHeight = trackRectHeight; m_ActionRect = new Rect(actionRectX, actionRectY, actionRectWidth, actionRectHeight); EGUI.DrawAreaLine(m_ActionRect, Color.blue); }
internal void OnGUI(Rect rect) { EGUI.DrawAreaLine(rect, Color.gray); Rect titleRect = new Rect(rect.x, rect.y, rect.width, TRACK_TITLE_HEIGHT); EditorGUI.LabelField(titleRect, Contents.titleContent, Styles.toolbar); EditorData data = EditorData.Data; DirectorSetting setting = DirectorSetting.GetSetting(); Rect clipRect = new Rect(rect.x, titleRect.y + titleRect.height, rect.width, rect.height - TRACK_TITLE_HEIGHT); if (data.CurrentDirector == null) { return; } int selectedIndex = -1; using (new GUI.ClipScope(clipRect)) { int trackStartIndex = Mathf.FloorToInt(setting.ScrollPosY / setting.TracklineHeight); int trackEndIndex = Mathf.CeilToInt((setting.ScrollPosY + clipRect.height) / setting.TracklineHeight); for (int i = trackStartIndex; i < trackEndIndex; ++i) { float y = setting.TracklineHeight * i - setting.ScrollPosY; if (i >= data.CurrentDirector.Tracks.Count) { break; } Track track = data.CurrentDirector.Tracks[i]; Rect trackIndexRect = new Rect(0, y, rect.width, setting.TracklineHeight); GUI.Label(trackIndexRect, $"{(track.Name ?? "")} ({i.ToString()})", data.SelectedTrackIndex == i ? "flow node 1" : "flow node 0"); if (Event.current.type == EventType.MouseUp && trackIndexRect.Contains(Event.current.mousePosition)) { selectedIndex = i; } } } if (clipRect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseUp) { if (selectedIndex >= 0 && Event.current.button == 0) { EditorData.Data.SelectedTrackIndex = selectedIndex; } else if (Event.current.button == 1) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(selectedIndex >= 0 ? "Insert" : "New"), false, () => { }); if (selectedIndex >= 0) { menu.AddItem(new GUIContent("Delete"), false, () => { }); if (selectedIndex > 0) { menu.AddItem(new GUIContent("Up"), false, () => { }); } if (selectedIndex < EditorData.Data.CurrentDirector.Tracks.Count - 1) { menu.AddItem(new GUIContent("Down"), false, () => { }); } } menu.ShowAsContext(); } Event.current.Use(); m_Window.Repaint(); } }
private void DrawTrack(Rect trackRect) { EGUI.DrawAreaLine(trackRect, Color.gray); LineSetting setting = LineSetting.Setting; Rect titleRect = new Rect(trackRect.x, trackRect.y, trackRect.width, TRACK_TITLE_HEIGHT); EditorGUI.LabelField(titleRect, "Tracks", EditorStyles.toolbar); if (Data == null) { return; } Rect clipRect = new Rect(trackRect.x, trackRect.y + TRACK_TITLE_HEIGHT, trackRect.width, trackRect.height - TRACK_TITLE_HEIGHT); using (new GUI.ClipScope(clipRect)) { int start = Mathf.FloorToInt(setting.ScrollPosY / setting.TracklineHeight); int end = Mathf.CeilToInt((setting.ScrollPosY + clipRect.height) / setting.TracklineHeight); Dictionary <Rect, int> rectIndexDic = new Dictionary <Rect, int>(); for (int i = start; i < end; ++i) { float y = setting.TracklineHeight * i - setting.ScrollPos.y; if (i >= Data.Tracks.Count) { break; } Rect indexRect = new Rect(0, y, trackWidth, setting.TracklineHeight); rectIndexDic.Add(indexRect, i); GUI.Label(indexRect, $"{(Data.Tracks[i].Name ?? "")} ({i.ToString()})", selectedTrackIndex == i ? "flow node 1" : "flow node 0"); } if (Event.current.type == EventType.MouseUp) { int index = -1; foreach (var kvp in rectIndexDic) { if (kvp.Key.Contains(Event.current.mousePosition)) { index = kvp.Value; break; } } if (Event.current.button == 1) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(index >= 0 ? "Insert New" : "Add New"), false, () => { OnTrackAdded(new TracklineData(), index); }); if (index >= 0) { menu.AddItem(new GUIContent("Delete"), false, () => { OnTrackDeleted(index); }); } menu.ShowAsContext(); } if (index >= 0) { OnTrackSelected(trackDrawers[index]); } Window.Repaint(); Event.current.Use(); } } }
public void OnDrawGUI(Rect rect) { LineSetting setting = LineSetting.Setting; Rect itemRect = Rect.zero; itemRect.x = Data.FireTime * setting.WidthForSecond - setting.ScrollPosX; itemRect.y = rect.y; itemRect.height = setting.TracklineHeight; itemRect.width = MIN_ACTION_WIDTH; DurationActionData durationActionData = null; if (Data is DurationActionData) { durationActionData = (DurationActionData)Data; itemRect.width = Mathf.Max(itemRect.width, durationActionData.DurationTime * setting.WidthForSecond); } else { itemRect.x -= itemRect.width * 0.5f; } GUI.Label(itemRect, BriefName, IsSelected ? "flow node 6" : "flow node 5"); int eventBtn = Event.current.button; EventType eventType = Event.current.type; bool isContains = itemRect.Contains(Event.current.mousePosition); Rect leftRect = new Rect(itemRect.x, itemRect.y, MIN_ACTION_WIDTH * 0.5f, itemRect.height); Rect rightRect = new Rect(itemRect.x + itemRect.width - MIN_ACTION_WIDTH * 0.5f, itemRect.y, MIN_ACTION_WIDTH * 0.5f, itemRect.height); bool isInLeftRect = false; bool isInRightRect = false; if (durationActionData != null && !durationActionData.IsFixedDurationTime) { EGUI.DrawAreaLine(leftRect, Color.yellow); EGUI.DrawAreaLine(rightRect, Color.yellow); EditorGUIUtility.AddCursorRect(leftRect, MouseCursor.ResizeHorizontal); EditorGUIUtility.AddCursorRect(rightRect, MouseCursor.ResizeHorizontal); isInLeftRect = leftRect.Contains(Event.current.mousePosition); isInRightRect = rightRect.Contains(Event.current.mousePosition); } if (eventBtn == 0) { if (eventType == EventType.MouseDown && isContains) { if (durationActionData != null) { if (isInLeftRect) { dragType = ActionDragType.ItemLeft; } else if (isInRightRect) { dragType = ActionDragType.ItemRight; } else { dragType = ActionDragType.Item; } } else { dragType = ActionDragType.Item; } IsSelected = true; Event.current.Use(); } else if (dragType != ActionDragType.None && eventType == EventType.MouseUp) { dragType = ActionDragType.None; Event.current.Use(); } else if (dragType != ActionDragType.None && IsSelected && eventType == EventType.MouseDrag) { Vector2 deltaPos = Event.current.delta; float deltaTime = deltaPos.x / setting.WidthForSecond; if (dragType == ActionDragType.ItemLeft) { if (Data.FireTime < durationActionData.DurationTime + Data.FireTime || deltaTime < 0) { Data.FireTime += deltaTime; durationActionData.DurationTime -= deltaTime; } } else if (dragType == ActionDragType.ItemRight) { durationActionData.DurationTime += deltaTime; } else if (dragType == ActionDragType.Item) { Data.FireTime += deltaTime; } float timeLength = ParentDrawer.ParentDrawer.Data.TimeLength; if (Data.FireTime < 0) { Data.FireTime = 0; } else if (Data.FireTime > timeLength) { Data.FireTime = timeLength; } if (durationActionData != null) { durationActionData.DurationTime = Mathf.Max(0.0f, durationActionData.DurationTime); float endTime = durationActionData.FireTime + durationActionData.DurationTime; if (endTime > timeLength) { durationActionData.DurationTime = Mathf.Min(durationActionData.DurationTime, timeLength - durationActionData.FireTime); } } Event.current.Use(); } } else if (eventBtn == 1 && isContains && eventType == EventType.MouseUp) { IsSelected = true; GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy"), false, () => { string actionJson = JsonConvert.SerializeObject(Data, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, }); setting.CopiedActionData = actionJson; }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Delete"), false, () => { ParentDrawer.OnActionDelete(this); }); menu.ShowAsContext(); Event.current.Use(); } }