示例#1
0
    private void OnGetReorderableList(SerializedProperty pProperty, ReorderableList pValue_Origin, ref ReorderableList pValue_Current)
    {
        object pPropertyData = EditorCodeHelper.GetTargetObjectOfProperty(pProperty);

        if (_mapInputInfo.ContainsKey(pPropertyData) == false)
        {
            _mapInputInfo[pPropertyData] = InputInfoElementGroup_Drawer.Get_ReorderableList(pProperty);
        }

        pValue_Current = _mapInputInfo[pPropertyData];
    }
示例#2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            base.OnGUI(position, property, label);

            position.y     += position.height - (EditorCodeHelper.singleLineHeight * 2);
            position.height = EditorCodeHelper.singleLineHeight;
            if (GUI.Button(position, "Calculate Result"))
            {
                var listCalculator = GetDrawTargetList(property);
                _iResult = listCalculator.DoCalculate_Relate();
            }
            position.y += EditorCodeHelper.singleLineHeight;

            EditorCodeHelper.LabelField(position, "Result: " + _iResult);
        }
示例#3
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();
    }
示例#4
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        float              fHeight             = EditorCodeHelper.singleLineHeight * 5;
        InputInfo          listDrawTarget      = EditorCodeHelper.GetTargetObjectOfProperty(property) as InputInfo;
        SerializedProperty pSP_ListCommandInfo = Get_List_SerializedProperty(property);

        if (pSP_ListCommandInfo != null)
        {
            for (int i = 0; i < pSP_ListCommandInfo.arraySize; i++)
            {
                SerializedProperty pProperty = pSP_ListCommandInfo.GetArrayElementAtIndex(i);
                if (pProperty.isExpanded)
                {
                    fHeight += GetElementHeight(pProperty);
                }
                else
                {
                    fHeight += EditorCodeHelper.singleLineHeight;
                }
            }
        }

        return(fHeight);
    }
    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);
    }
 static protected RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT> GetDrawTargetList(SerializedProperty property)
 {
     return(EditorCodeHelper.GetTargetObjectOfProperty(property) as RelatedByElementsListBase <CLASS_ELEMENT, TYPE_ITEM_RELATE, TYPE_RESULT>);
 }
    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);
    }
示例#8
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);
            }
        });
    }
示例#9
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        InputInfoElement pDrawTarget = EditorCodeHelper.GetTargetObjectOfProperty(property) as InputInfoElement;

        position.height     = EditorCodeHelper.singleLineHeight;
        property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, "Input: " + pDrawTarget.IRelateByOther_GetDisplayName());
        if (property.isExpanded == false)
        {
            return;
        }
        position.y += EditorCodeHelper.singleLineHeight;

        EditorCodeHelper.PropertyField(position, property.FindPropertyRelative(nameof(pDrawTarget.eInputInfoType)), "InputType");
        position.y += EditorCodeHelper.singleLineHeight;

        if (pDrawTarget.eInputInfoType == InputInfoElement.EInputInfoType.GetAxis)
        {
            var listInput = InputSetting.GetInput_ValueDropDownList();
            pDrawTarget.strInputAxisName = EditorCodeHelper.DrawEnumPopup(position, "Select Input", pDrawTarget.strInputAxisName, listInput);
            position.y += EditorCodeHelper.singleLineHeight;
        }
        else if (pDrawTarget.IsMouseInput())
        {
            EditorCodeHelper.PropertyField(position, property.FindPropertyRelative(nameof(pDrawTarget.eMouseButtonType)), "Mouse");
            position.y += EditorCodeHelper.singleLineHeight;
        }
        else
        {
            float fOriginX     = position.x;
            float fOriginWidth = position.width;
            position.width *= 0.5f;
            position.x     += position.width;

            var pKeyCodeProperty = property.FindPropertyRelative(nameof(pDrawTarget.eKeyCode));
            if (pKeyCodeProperty.isExpanded) // Is Recording..
            {
                if (UpdateKeyCode(property, pDrawTarget))
                {
                    pKeyCodeProperty.isExpanded = false;
                }

                if (GUI.Button(position, "Cancel Recording.."))
                {
                    pKeyCodeProperty.isExpanded = false;
                }
            }
            else
            {
                if (GUI.Button(position, "Record KeyCode"))
                {
                    pKeyCodeProperty.isExpanded = true;
                }
            }

            position.x     = fOriginX;
            position.width = fOriginWidth;
            position.y    += EditorCodeHelper.singleLineHeight;

            pKeyCodeProperty.intValue = (int)pDrawTarget.eKeyCode;
            EditorCodeHelper.PropertyField(position, pKeyCodeProperty, "KeyCode");
            position.y += EditorCodeHelper.singleLineHeight;
        }

        EditorCodeHelper.PropertyField(position, property.FindPropertyRelative(nameof(pDrawTarget.bAlwaysInput)), "Is Always Input");
        position.y += EditorCodeHelper.singleLineHeight;
    }