コード例 #1
0
            public WindowComponentParametersBase OnComponentChanged(WindowBase window, WindowComponent newComponent)
            {
                var hasChanged = (newComponent != this.component);

                this.component = newComponent;

                WindowComponentParametersBase instance = null;

                if (hasChanged == true)
                {
                                        #if UNITY_EDITOR
                    if (this.componentParameters != null)
                    {
                        var link = this.componentParameters;
                        //UnityEditor.EditorApplication.delayCall += () => {

                        Object.DestroyImmediate(link, allowDestroyingAssets: true);

                        //};
                    }
                                        #endif

                    instance = Layout.AddParametersFor(window, this.component);
                    this.componentParameters = instance;
                }
                else
                {
                    instance = this.componentParameters;
                }

                return(instance);
            }
コード例 #2
0
        private void VerifyParameters()
        {
            this.parameters = this.target as WindowComponentParametersBase;
            this.fields     = this.parameters.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);

            this.values     = new long[this.fields.Length];
            this.properties = new SerializedProperty[this.fields.Length];
            for (int i = 0; i < this.properties.Length; ++i)
            {
                this.properties[i] = this.serializedObject.FindProperty(this.fields[i].Name);
                var attrs = this.fields[i].GetCustomAttributes(false);
                if (attrs != null && attrs.Length > 0)
                {
                    var attr = attrs.FirstOrDefault((a) => a is ParamFlagAttribute) as ParamFlagAttribute;
                    if (attr != null)
                    {
                        this.values[i] = attr.flag;
                    }
                }
            }

            this.referenceHeight = 16f;

            /*var referenceField = this.fields.FirstOrDefault((f) => f.GetCustomAttributes(false).Count() == 0);
             * var referenceIndex = System.Array.IndexOf(this.fields, referenceField);
             * if (referenceIndex >= 0) {
             *
             *      this.referenceHeight = EditorGUI.GetPropertyHeight(this.properties[referenceIndex]);
             *
             * }*/
        }
コード例 #3
0
            public WindowComponentParametersBase OnComponentChanged(WindowBase window, WindowComponent newComponent)
            {
                var hasChanged = (newComponent != this.component);

                this.component = newComponent;

                WindowComponentParametersBase instance = null;

                if (hasChanged == true)
                {
                    if (newComponent == null)
                    {
                        this.componentResource.ResetToDefault();
                    }

                    if (this.componentParameters != null)
                    {
                        var link = this.componentParameters;
                        //UnityEditor.EditorApplication.delayCall += () => {

                        Object.DestroyImmediate(link, allowDestroyingAssets: true);

                        //};
                    }

                    instance = Layout.AddParametersFor(window, this.component);
                    this.componentParameters = instance;

                    this.OnValidate();
                }
                else
                {
                    instance = this.componentParameters;
                }

                return(instance);
            }