public static void RightClickMenu(Rect rect, float width, float height, RVSettingData settingData, string menuName, GenericMenu.MenuFunction2 onClick, string text, bool isSelected) { Event currentEvent = Event.current; Rect contextRect = new Rect(rect.x, rect.y, width, height); if (isSelected == true) { EditorGUI.DrawRect(contextRect, settingData.bgColor_selected); } else { EditorGUI.DrawRect(contextRect, new Color(0, 0, 0, 0)); } if (currentEvent.type == EventType.ContextClick) { Vector2 mousePos = currentEvent.mousePosition; if (contextRect.Contains(mousePos)) { // Now create the menu, add items and show it GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(menuName), false, onClick, text); menu.ShowAsContext(); currentEvent.Use(); } } }
GUIStyle SelectNameGUIStyle(RVSettingData settingData) { GUIStyle _nowStyle = settingData.Get_default(); if (this.rvVisibility.RVType == RVVisibility.NameType.Field) { if (this.rvVisibility.IsPublic == true) { _nowStyle = settingData.Get_name_public(); } else { _nowStyle = settingData.Get_name_private(); } } else if (this.rvVisibility.RVType == RVVisibility.NameType.CollectionItem) { _nowStyle = settingData.Get_name_collection_item(); } else if (this.rvVisibility.RVType == RVVisibility.NameType.Property) { _nowStyle = settingData.Get_name_property(); } return(_nowStyle); }
public override void OnGUIUpdate(bool isRealtimeUpdate, RVSettingData settingData, RVCStatus rvcStatus) { string s = GetValueString(this.data); isSelected = rvcStatus.IsSelected(this.NameLabel); if (isSelected == false) { isSelected = rvcStatus.IsSelected(s); } GUIStyle guiStyle = SelectNameGUIStyle(settingData); GUIStyle value_guiStyle = SelectValueGUIStyle(settingData); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" ", GUILayout.Width(depth * RVControlBase.Indent_field)); EditorGUILayout.LabelField(this.NameLabel + " :", guiStyle, GUILayout.Width(GetWidth(this.NameLabel, settingData))); CopyMenu(GUILayoutUtility.GetLastRect(), settingData, this.NameLabel, s); if (this.data == null && this.rvVisibility.ValueTypeIsString() == false) { EditorGUILayout.LabelField(s, settingData.Get_value_null()); } else { EditorGUILayout.LabelField(s, value_guiStyle); } EditorGUILayout.EndHorizontal(); }
void CopyMenu(Rect rect, RVSettingData settingData, string name, string value) { Event currentEvent = Event.current; Rect contextRect = new Rect(rect.x, rect.y, 1200, 16); if (isSelected == true) { EditorGUI.DrawRect(contextRect, settingData.bgColor_selected); } else { EditorGUI.DrawRect(contextRect, new Color(0, 0, 0, 0)); } if (currentEvent.type == EventType.ContextClick) { Vector2 mousePos = currentEvent.mousePosition; if (contextRect.Contains(mousePos)) { // Now create the menu, add items and show it GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy name"), false, delegate(object obj) { EditorGUIUtility.systemCopyBuffer = obj.ToString(); }, name); menu.AddItem(new GUIContent("Copy value"), false, delegate(object obj) { EditorGUIUtility.systemCopyBuffer = obj.ToString(); }, value); menu.ShowAsContext(); currentEvent.Use(); } } }
GUIStyle GetCollectionGUIStyle(RVSettingData settingData) { if (this.rvVisibility.RVType == RVVisibility.NameType.Class) { return(settingData.Get_name_class(EditorStyles.foldout)); } return(settingData.Get_name_container(EditorStyles.foldout)); }
bool CollectionUI(bool isOpen, RVSettingData settingData) { bool isSelected = this.rvcStatus.IsSelected(this.NameLabel); GUIStyle guistyle = settingData.Get_name_container(EditorStyles.foldout); if (this.rvVisibility.RVType == RVVisibility.NameType.Class) { guistyle = settingData.Get_name_class(EditorStyles.foldout); } isOpen = EditorGUILayout.Foldout(isOpen, new GUIContent(this.NameLabel), guistyle); RVText.RightClickMenu(GUILayoutUtility.GetLastRect(), 1200, 16, settingData, "Copy", RVText.OnMenuClick_Copy, this.NameLabel, isSelected); return(isOpen); }
float GetWidth(string str, RVSettingData settingData) { int count = 2; int bigCount = 0; foreach (char item in str) { if (item >= 'a' && item <= 'z') { count++; } else { bigCount++; } } return(count * settingData.LowercaseLength + bigCount * settingData.UppercaseLength); }
GUIStyle SelectValueGUIStyle(RVSettingData settingData) { GUIStyle _nowStyle = settingData.Get_value_others(); if (RVHelper.IsString(this.rvVisibility.ValueType) == true) { _nowStyle = settingData.Get_value_string(); } else if (RVHelper.IsEnum(this.rvVisibility.ValueType) == true) { _nowStyle = settingData.Get_value_enum(); } else if (RVHelper.IsNormalType(this.rvVisibility.ValueType) == true) { _nowStyle = settingData.Get_value_digital(); } return(_nowStyle); }
public override void OnGUIUpdate(bool isRealtimeUpdate, RVSettingData settingData, RVCStatus rvcStatus) { this.settingData = settingData; this.rvcStatus = rvcStatus; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" ", GUILayout.Width(depth * RVControlBase.Indent_class)); string rvcStatusName = this.parentNameLabel + this.NameLabel; if (rvcStatus.IsOpens.ContainsKey(rvcStatusName) == false) { rvcStatus.IsOpens.Add(rvcStatusName, false); } EditorGUILayout.BeginVertical(); rvcStatus.IsOpens[rvcStatusName] = CollectionUI(rvcStatus.IsOpens[rvcStatusName], settingData); if (rvcStatus.IsOpens[rvcStatusName] == true) { if (isFirstOpen == true) { AnalyzeAndAddChildren(); isFirstOpen = false; } else if (isRealtimeUpdate == true) { AnalyzeAndAddChildren(); } foreach (var item in children) { item.OnGUIUpdate(isRealtimeUpdate, settingData, rvcStatus); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
public virtual void OnGUIUpdate(bool isRealtimeUpdate, RVSettingData settingData, RVCStatus rvcStatus) { }
//绘制窗口时调用 void OnGUI() { if (settingData == null) { settingData = Resources.Load <RVSettingData>("RVSettingData"); if (settingData == null) { Debug.LogError("RuntimeViewer -> error : can't find RVSettingData prefab ..."); } } //ver text GUILayout.Space(space_vertical); GUILayout.Label(_ver); GUILayout.Space(space_vertical); GUI.color = new Color(1f, 1f, 0.8f); if (GUILayout.Button("-- Set Default Data --", GUILayout.Width(200))) { settingData.SetToDefault(); } GUI.color = Color.white; GUILayout.Space(space_vertical); //bool control IsRealtimeUpdate = EditorGUILayout.Toggle("Is Open Realtime Update", IsRealtimeUpdate); // IsRealtimeUpdate = EditorGUILayout.Toggle("Is Open Realtime Update", IsRealtimeUpdate); bool b = IsEnableForbidNames; b = EditorGUILayout.Toggle("Is Enable Forbid List", b); if (IsEnableForbidNames != b) { Refresh(); } IsEnableForbidNames = b; GUI.color = new Color(0.8f, 1f, 0.8f); if (GUILayout.Button("-- Refresh --", GUILayout.Width(200))) { Refresh(); } GUI.color = Color.white; // search control GUILayout.Space(2); SearchBar(); //content GUILayout.Space(space_vertical); UpdateNowSelectItem(); EditorGUILayout.BeginHorizontal(); if (nowSelectItem != null) { GUILayout.Label("Select Item : " + nowSelectItem.name); } else { GUILayout.Label("Select Item : is null"); } FoldRVCStatus(); EditorGUILayout.EndHorizontal(); if (nowSelectItem != null) { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); foreach (var item in rvCollections) { item.Value.SearchString = this.searchString.ToLower(); item.Key.OnGUIUpdate(IsRealtimeUpdate, settingData, item.Value); } EditorGUILayout.EndScrollView(); } }