/************************************************************************************************************************/

        private void DoPersistentCallGUI(Rect area, int index, bool isActive, bool isFocused)
        {
            DrawerState.Current.callIndex = index;
            var callProperty = _CurrentCallList.serializedProperty.GetArrayElementAtIndex(index);

            area.x      += Border;
            area.y      += Border;
            area.height -= Border * 2;

            PersistentCallDrawer.includeRemoveButton = true;

            EditorGUI.PropertyField(area, callProperty);

            if (PersistentCallDrawer.DoRemoveButtonGUI(area))
            {
                DelayedRemoveCall(index);
            }

            if (isFocused)
            {
                CheckInput(index);
            }

            DrawerState.Current.callIndex = -1;
        }
        /************************************************************************************************************************/

        private static void AddCoreItems(Object[] targets)
        {
            _Menu.AddItem(new GUIContent("Null"), _CurrentMethod == null, () =>
            {
                DrawerState.Current.CopyFrom(CachedState);

                if (targets != null)
                {
                    PersistentCallDrawer.SetMethod(null);
                }
                else
                {
                    // For a static method, remove the method name but keep the declaring type.
                    var methodName = CachedState.MethodNameProperty.stringValue;
                    var lastDot    = methodName.LastIndexOf('.');
                    if (lastDot < 0)
                    {
                        CachedState.MethodNameProperty.stringValue = null;
                    }
                    else
                    {
                        CachedState.MethodNameProperty.stringValue = methodName.Substring(0, lastDot + 1);
                    }

                    CachedState.PersistentArgumentsProperty.arraySize = 0;

                    CachedState.MethodNameProperty.serializedObject.ApplyModifiedProperties();
                }

                DrawerState.Current.Clear();
            });

            var isStatic = _CurrentMethod != null && _CurrentMethod.IsStatic;

            if (targets != null && !isStatic)
            {
                _Menu.AddItem(new GUIContent("Static Method"), isStatic, () =>
                {
                    DrawerState.Current.CopyFrom(CachedState);

                    PersistentCallDrawer.SetTarget(null);

                    DrawerState.Current.Clear();
                });
            }

            _Menu.AddSeparator("");
        }
Esempio n. 3
0
        /************************************************************************************************************************/

        private void DoPersistentCallGUI(Rect area, int index, bool isActive, bool isFocused)
        {
            DrawerState.Current.callIndex = index;
            var callProperty = _CurrentCallList.serializedProperty.GetArrayElementAtIndex(index);

            area.x      += Border;
            area.y      += Border;
            area.height -= Border * 2;

            float originalAreaX      = area.x;
            float originalAreaWidth  = area.width;
            float originalAreaHeight = area.height;
            float delayPropertyWidth = 44f;

            area.width -= delayPropertyWidth;
            area.height = EditorGUIUtility.singleLineHeight;

            PersistentCallDrawer.includeRemoveButton = true;

            EditorGUI.PropertyField(area, callProperty);

            area.x    += area.width - 15f;
            area.width = delayPropertyWidth - 18f;

            EditorGUI.PropertyField(area, callProperty.FindPropertyRelative("MethodDelay"), GUIContent.none);

            area.x      = originalAreaX;
            area.width  = originalAreaWidth;
            area.height = originalAreaHeight;

            if (PersistentCallDrawer.DoRemoveButtonGUI(area))
            {
                DelayedRemoveCall(index);
            }

            if (isFocused)
            {
                CheckInput(index);
            }

            DrawerState.Current.callIndex = -1;
        }
Esempio n. 4
0
        private void AddNewCall(ReorderableList list, Object target)
        {
            var index = list.index;

            if (index >= 0 && index < _CurrentCallCount)
            {
                index++;
                list.index = index;
            }
            else
            {
                index = _CurrentCallCount;
            }

            list.serializedProperty.InsertArrayElementAtIndex(index);

            list.serializedProperty.serializedObject.ApplyModifiedProperties();

            var callProperty = list.serializedProperty.GetArrayElementAtIndex(index);

            DrawerState.Current.BeginCall(callProperty);
            PersistentCallDrawer.SetTarget(target);
            DrawerState.Current.EndCall();
        }