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

        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. 2
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();
        }