Exemple #1
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        InputInfoElementGroup_Drawer.p_Event_OnGetReorderableList.Subscribe += OnGetReorderableList;

        SerializedObject   pSO = property.serializedObject;
        SerializedProperty pSP_ListCommandInfo = Get_List_SerializedProperty(property);
        InputInfoList      pDrawTarget         = EditorCodeHelper.GetTargetObjectOfProperty(property) as InputInfoList;

        if (_listCommandInfo == null)
        {
            _mapInputInfo.Clear();

            _listCommandInfo = new ReorderableList(pSO, pSP_ListCommandInfo, true, true, true, true);
            _listCommandInfo.drawElementCallback = DrawElement(pSO, pDrawTarget);

            _listCommandInfo.drawHeaderCallback = (Rect rect) =>
            {
                EditorCodeHelper.LabelField(rect, property.displayName);
            };

            _listCommandInfo.elementHeightCallback = (int index) =>
            {
                var element = _listCommandInfo.serializedProperty.GetArrayElementAtIndex(index);
                if (element.isExpanded)
                {
                    return(GetElementHeight(element));
                }
                else
                {
                    return(EditorCodeHelper.singleLineHeight);
                }
            };
        }

        _listCommandInfo.DoList(position);
        pSO.ApplyModifiedProperties();
    }
Exemple #2
0
    private ReorderableList.ElementCallbackDelegate DrawElement(SerializedObject pSO, InputInfoList pDrawTarget)
    {
        return((Rect rect, int index, bool isActive, bool isFocused) =>
        {
            InputInfo pCommandInfo = pDrawTarget.listCommandInfo[index];

            rect.width -= 15f;
            rect.x += 10f;

            float fOrigin_RectX = rect.x;
            float fOriginRectWidth = rect.width;

            var pSP_Element = _listCommandInfo.serializedProperty.GetArrayElementAtIndex(index);
            var pProeprty_ListInputInfoList = pSP_Element.FindPropertyRelative(nameof(pCommandInfo.pInputInfoGroup));
            InputInfoElementGroup pInputInfoGroup = EditorCodeHelper.GetTargetObjectOfProperty(pProeprty_ListInputInfoList) as InputInfoElementGroup;

            rect.height = EditorCodeHelper.singleLineHeight;
            rect.width *= 0.5f;
            rect.x += rect.width;

            if (pDrawTarget.pCommandListTarget != null)
            {
                System.Type pCommandType = null;
                var listCommandType = pDrawTarget.pCommandListTarget.GetCommandList();
                foreach (var pType in listCommandType)
                {
                    if (pType.Value.FullName.Equals(pCommandInfo.strCommandTypeName))
                    {
                        pCommandType = pType.Value;
                        break;
                    }
                }

                int iSelectIndex = EditorGUI.Popup(rect, listCommandType.Calculate_SelectIndex(pCommandType), listCommandType.GetNameList());
                pCommandType = listCommandType[iSelectIndex].Value;
                if (pCommandType != null)
                {
                    pCommandInfo.strCommandTypeName = pCommandType.FullName;
                    pCommandInfo.strAssemblyName = pCommandType.Assembly.FullName;
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(pSO.targetObject);
                }
            }
            else
            {
                EditorGUI.LabelField(rect, "Command is Null");
            }

            rect.width = fOriginRectWidth;
            rect.x = fOrigin_RectX;
            pSP_Element.isExpanded = EditorCodeHelper.Foldout(rect, pSP_Element.isExpanded, "Command");
            if (pSP_Element.isExpanded)
            {
                rect.y += EditorCodeHelper.singleLineHeight;
                EditorGUI.PropertyField(rect, pProeprty_ListInputInfoList, true);
            }
        });
    }