public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float fHeight = EditorCodeHelper.singleLineHeight * 4; RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT> listDrawTarget = EditorCodeHelper.GetTargetObjectOfProperty(property) as RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT>; SerializedProperty plistProperty = Get_List_SerializedProperty(property); if (plistProperty != null) { if (listDrawTarget.Check_IsError()) { fHeight += EditorCodeHelper.singleLineHeight * 2; } for (int i = 0; i < plistProperty.arraySize; i++) { SerializedProperty pProperty = plistProperty.GetArrayElementAtIndex(i); if (pProperty.isExpanded) { fHeight += GetElementHeight(pProperty); } else { fHeight += EditorCodeHelper.singleLineHeight; } } } return(fHeight); }
public ValueDropdownList <CLASS_ELEMENT> GetValueDropdownList(RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT> listDrawTarget, List <CLASS_ELEMENT> list, CLASS_ELEMENT pElementIgnore) { ValueDropdownList <CLASS_ELEMENT> listReturn = new ValueDropdownList <CLASS_ELEMENT>(); listReturn.Clear(); for (int i = 0; i < list.Count; i++) { CLASS_ELEMENT pElement = list[i]; if (pElement.Equals(pElementIgnore) == false) { listReturn.Add($"{i}).{listDrawTarget.GetElementDisplayName(pElement)}", pElement); } } if (listReturn.Count == 0) { listReturn.Add($"Require Other Element", default(CLASS_ELEMENT)); } return(listReturn); }
static public ReorderableList Get_ReorderableList(SerializedProperty property) { RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT> listDrawTarget = GetDrawTargetList(property); SerializedProperty pSP_List = Get_List_SerializedProperty(property); ReorderableList listInput = new ReorderableList(property.serializedObject, pSP_List, true, true, true, true); listInput.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { var pPropertyElement = listInput.serializedProperty.GetArrayElementAtIndex(index); CLASS_ELEMENT pElement = EditorCodeHelper.GetTargetObjectOfProperty(pPropertyElement) as CLASS_ELEMENT; if (pElement == null) { return; } rect.width -= 15f; float fRectWidth_Origin = rect.width; rect.x -= EditorGUI.indentLevel * 15f; rect.width = const_fToggleWidth - 15f; pElement.bEnable = EditorGUI.Toggle(rect, pElement.bEnable); rect.x += const_fToggleWidth; rect.width = fRectWidth_Origin - rect.width; EditorCodeHelper.PropertyField(rect, pPropertyElement, listDrawTarget.GetElementDisplayName(pElement)); rect.y += EditorGUI.GetPropertyHeight(pPropertyElement, true); int iIndetOrigin = EditorGUI.indentLevel; if (pPropertyElement.isExpanded) { EditorGUI.indentLevel++; ValueDropdownList <TYPE_ITEM_RELATE> listRelateType = pElement.IRelateByOther_GetEditorDisplayNameList(); pElement.pRelateType = EditorCodeHelper.DrawEnumPopup(rect, "Related Type", pElement.pRelateType, listRelateType); rect.y += EditorCodeHelper.singleLineHeight * 2; float fRectOriginX = rect.x; float fBracketCount_LabelWidth = EditorCodeHelper.CalcSize($"\"(\" Count :00") + 40f; rect.width = fBracketCount_LabelWidth; EditorCodeHelper.LabelField(rect, $"\"(\" Count :{pElement.iBracket_Start_Count.ToString()}"); rect.x += fBracketCount_LabelWidth; float fLabelWidth = EditorCodeHelper.CalcSize("Add \"(\"") + const_fDrawBracketButton_Padding; rect.width = fLabelWidth; rect.height = EditorCodeHelper.singleLineHeight; if (GUI.Button(rect, "Add \"(\"")) { pElement.iBracket_Start_Count++; } rect.x += fLabelWidth + const_fDrawBracketButton_Gap; fLabelWidth = EditorCodeHelper.CalcSize("Remove \"(\"") + const_fDrawBracketButton_Padding; rect.width = fLabelWidth; if (pElement.IRelateByOther_IsBracket_Start()) { if (GUI.Button(rect, "Remove \"(\"")) { pElement.iBracket_Start_Count--; } } rect.y += EditorCodeHelper.singleLineHeight; rect.x = fRectOriginX; rect.width = fBracketCount_LabelWidth; EditorCodeHelper.LabelField(rect, $"\")\" Count :{pElement.iBracket_Finish_Count.ToString()}"); rect.x += fBracketCount_LabelWidth; fLabelWidth = EditorCodeHelper.CalcSize("Add \")\"") + const_fDrawBracketButton_Padding; rect.width = fLabelWidth; if (GUI.Button(rect, "Add \")\"")) { pElement.iBracket_Finish_Count++; } rect.x += fLabelWidth + const_fDrawBracketButton_Gap; fLabelWidth = EditorCodeHelper.CalcSize("Remove \")\"") + const_fDrawBracketButton_Padding; rect.width = fLabelWidth; if (pElement.IRelateByOther_IsBracket_Finish()) { if (GUI.Button(rect, "Remove \")\"")) { pElement.iBracket_Finish_Count--; } } rect.width = fRectWidth_Origin; rect.x = fRectOriginX; rect.y += EditorCodeHelper.singleLineHeight; } EditorGUI.indentLevel = iIndetOrigin; }; listInput.drawHeaderCallback = (Rect rect) => { string strDisplayName = $"[{property.displayName}]= {listDrawTarget.ToString()}"; EditorCodeHelper.LabelField(rect, strDisplayName); }; listInput.elementHeightCallback = (int index) => { var element = listInput.serializedProperty.GetArrayElementAtIndex(index); return(GetElementHeight(element)); }; return(listInput); }