public ExposedMethodField CreateExposedMethodButton(ExposedMethod method, Getter getter, Setter setter)
        {
            ExposedMethodField methodDrawer = (ExposedMethodField)Inspector.CreateDrawerForType(typeof(ExposedMethod), drawArea, Depth + 1, false);

            if (methodDrawer != null)
            {
                methodDrawer.BindTo(typeof(ExposedMethod), string.Empty, getter, setter);
                methodDrawer.SetBoundMethod(method);

                exposedMethods.Add(methodDrawer);
            }

            return(methodDrawer);
        }
        private void GenerateExposedMethodButtons()
        {
            if (Inspector.ShowRemoveComponentButton && typeof(Component).IsAssignableFrom(BoundVariableType) && !typeof(Transform).IsAssignableFrom(BoundVariableType))
            {
                CreateExposedMethodButton(GameObjectField.removeComponentMethod, () => this, (value) => { });
            }

            ExposedMethod[] methods = BoundVariableType.GetExposedMethods();
            if (methods != null)
            {
                bool isInitialized = Value != null && !Value.Equals(null);
                for (int i = 0; i < methods.Length; i++)
                {
                    ExposedMethod method = methods[i];
                    if ((isInitialized && method.VisibleWhenInitialized) || (!isInitialized && method.VisibleWhenUninitialized))
                    {
                        CreateExposedMethodButton(method, () => Value, (value) => Value = value);
                    }
                }
            }
        }
Esempio n. 3
0
        private void GenerateMethods()
        {
            ExposedMethod[] methods = BoundVariableType.GetExposedMethods();
            if (methods != null)
            {
                bool isInitialized = Value != null && !Value.Equals(null);
                for (int i = 0; i < methods.Length; i++)
                {
                    ExposedMethod method = methods[i];
                    if ((isInitialized && method.VisibleWhenInitialized) || (!isInitialized && method.VisibleWhenUninitialized))
                    {
                        ExposedMethodField methodDrawer = (ExposedMethodField)Inspector.CreateDrawerForType(typeof(ExposedMethod), drawArea, Depth + 1, false);
                        if (methodDrawer != null)
                        {
                            methodDrawer.BindTo(typeof(ExposedMethod), string.Empty, () => Value, (value) => Value = value);
                            methodDrawer.SetBoundMethod(method);

                            exposedMethods.Add(methodDrawer);
                        }
                    }
                }
            }
        }
 public void SetBoundMethod(ExposedMethod boundMethod)
 {
     this.boundMethod = boundMethod;
     NameRaw          = boundMethod.Label;
 }