Exemple #1
0
        public override void OnValidateEditor()
        {
            base.OnValidateEditor();

            //if (this.gameObject.activeSelf == false) return;

            #region source macros UI.Windows.Editor.ImageComponent
            {
                //if (this.image == null) this.image = this.GetComponent<Image>();
                //if (this.rawImage == null) this.rawImage = this.GetComponent<RawImage>();

                WindowSystemResources.Validate(this);

                this.imageCrossFadeModule.Init(this);
                this.imageCrossFadeModule.OnValidateEditor();

                /*if (this.image == null || this.image.GetComponent<UIFlippable>() == null ||
                 *      this.rawImage == null || this.rawImage.GetComponent<UIFlippable>() == null) {
                 *
                 *      if (this.flippableEffect != null) ME.EditorUtilities.Destroy(this.flippableEffect, () => { this.flippableEffect = null; });
                 *
                 * }
                 *
                 * if (this.rawImage == null || this.rawImage.GetComponent<UIPreserveAspect>() == null) {
                 *
                 *      if (this.preserveAspectEffect != null) ME.EditorUtilities.Destroy(this.preserveAspectEffect, () => { this.preserveAspectEffect = null; });
                 *
                 * }*/

                var gr = (this.rawImage as Graphic ?? this.image as Graphic);
                if (gr != null)
                {
                    this.flippableEffect = gr.GetComponent <UIFlippable>();
                    if (this.flippableEffect == null)
                    {
                        this.flippableEffect = gr.gameObject.AddComponent <UIFlippable>();
                    }
                    if (this.flippableEffect != null)
                    {
                        this.flippableEffect.horizontal = this.flipHorizontal;
                        this.flippableEffect.vertical   = this.flipVertical;
                    }
                }

                if (this.rawImage != null)
                {
                    this.preserveAspectEffect = this.rawImage.GetComponent <UIPreserveAspect>();
                    if (this.preserveAspectEffect == null)
                    {
                        this.preserveAspectEffect = this.rawImage.gameObject.AddComponent <UIPreserveAspect>();
                    }
                    if (this.preserveAspectEffect != null)
                    {
                        this.preserveAspectEffect.preserveAspect = this.preserveAspect;
                        this.preserveAspectEffect.rawImage       = this.rawImage;
                    }
                }
            }
            #endregion
        }
Exemple #2
0
 private void CopyPreserveAspect(bool isPreserveAspect, Graphic graphic, UIPreserveAspect copy)
 {
     copy.preserveAspect = isPreserveAspect;
     copy.rawImage       = graphic as RawImage;
 }