//type: 消息类型 text:文本 image:图片 bp:霸屏 ds打sang hb hong包 bb表白 gift送礼 ... public ETextType ParseType(string type) { ETextType result = ETextType.ETextType_other; //default... if ("text" == type) { result = ETextType.ETextType_TEXT; } else if ("image" == type) { result = ETextType.ETextType_PICTURE; } else if ("bp" == type) { result = ETextType.ETextType_BAPING; } else { //nothing to do. } return(result); }
/// <summary> /// Create a reorderable list that will display the various coloring elements /// </summary> /// <returns>Returns a Reorderable list that can be displayed with specified values</returns> private ReorderableList CreateReorderableList() { //Store a reference to the array of objects that will be processed List <ColoringValues> values = HierarchyColoringProcessor.toProcess; //Create the list of objects to be displayed ReorderableList list = new ReorderableList(values, typeof(ColoringValues), true, true, true, true); //Override the drawing elements to use the property defaults list.elementHeightCallback += (index) => (EditorGUIUtility.singleLineHeight + LINE_BUFFER_SPACE) * (values[index].overrideTextColor ? 4.05f : 3.05f); list.drawHeaderCallback = (Rect rect) => EditorGUI.LabelField(rect, processingHeader); list.drawElementCallback += (Rect rect, int index, bool isActive, bool isFocused) => { //Display the enumeration option as the first selection option ETextType newType = (ETextType)EditorGUI.EnumPopup( new Rect(rect.x, rect.y, rect.width * .2f, EditorGUIUtility.singleLineHeight), values[index].textType ); //If the option is changed, clear the previous text value if (newType != values[index].textType) { //Set the new type value values[index].textType = newType; //Set a default text value based on the selection type switch (newType) { case ETextType.Tag: values[index].text = "Untagged"; break; case ETextType.Layer: values[index].text = "0"; break; default: values[index].text = string.Empty; break; } } //Switch based on the type that is to be displayed switch (newType) { //Simple options that can be easily processed case ETextType.Tag: values[index].text = EditorGUI.TagField( new Rect(rect.x + rect.width * .225f, rect.y, rect.width * .775f, EditorGUIUtility.singleLineHeight), values[index].text ); break; case ETextType.Layer: values[index].text = EditorGUI.LayerField( new Rect(rect.x + rect.width * .225f, rect.y, rect.width * .775f, EditorGUIUtility.singleLineHeight), int.Parse(values[index].text) ).ToString(); break; case ETextType.Name: values[index].text = EditorGUI.DelayedTextField( new Rect(rect.x + rect.width * .225f, rect.y, rect.width * .775f, EditorGUIUtility.singleLineHeight), values[index].text ); break; //Check for type entering or menu selection case ETextType.Type: //Display a text field for manual entry of a search type string newTypeText = EditorGUI.DelayedTextField( new Rect(rect.x + rect.width * .225f, rect.y, rect.width * .725f, EditorGUIUtility.singleLineHeight), values[index].text ); //If the type text changes, try to find a type that matches if (newTypeText != values[index].text) { //Try to find a type that matches what was entered for (int i = 0; i < SEARCH_ASSEMBLIES.Length; ++i) { Type found = SEARCH_ASSEMBLIES[i].GetType(newTypeText, false); if (found != null) { newTypeText = MinifyTypeAssemblyName(found); break; } } //Assign the new type text to this entry values[index].text = newTypeText; } //Display a button that can be used to quick select possible types if (EditorGUI.DropdownButton(new Rect(rect.x + rect.width * .95f, rect.y, rect.width * .05f, EditorGUIUtility.singleLineHeight), GUIContent.none, FocusType.Passive)) { //Store a lambda-catchable object reference that can be modified ColoringValues toModify = values[index]; //Create the callback for the generic menu onTypeSelected = type => toModify.text = MinifyTypeAssemblyName(type); //Show the type options that are usable TYPE_SELECTION_MENU.ShowAsContext(); } break; } //Display the color value that will be used to highlight the nominated objects values[index].color = EditorGUI.ColorField( new Rect(rect.x, rect.y + (EditorGUIUtility.singleLineHeight + LINE_BUFFER_SPACE) * 1f, rect.width, EditorGUIUtility.singleLineHeight), colorLabel, values[index].color ); //Display the toggle field for setting the text override color bool isOverridden = values[index].overrideTextColor; values[index].overrideTextColor = EditorGUI.Toggle( new Rect(rect.x, rect.y + (EditorGUIUtility.singleLineHeight + LINE_BUFFER_SPACE) * 2f, rect.width, EditorGUIUtility.singleLineHeight), overrideLabel, values[index].overrideTextColor ); //Check if the text color override should be displayed for modification if (isOverridden) { values[index].textColor = EditorGUI.ColorField( new Rect(rect.x, rect.y + (EditorGUIUtility.singleLineHeight + LINE_BUFFER_SPACE) * 3f, rect.width, EditorGUIUtility.singleLineHeight), textColLabel, values[index].textColor ); } }; return(list); }