Пример #1
0
		public override void OnValidateEditor() {

			base.OnValidateEditor();

			if (Application.isPlaying == true) return;

			if (this.canvasUpdater == null || this.GetComponents<CanvasUpdater>().Length > 1) {

				if (this.GetComponent<CanvasUpdater>() != null) Component.DestroyImmediate(this.GetComponent<CanvasUpdater>());
				this.canvasUpdater = this.GetComponent<CanvasUpdater>();
				if (this.canvasUpdater == null) this.canvasUpdater = this.gameObject.AddComponent<CanvasUpdater>();
				if (this.canvasUpdater != null) this.canvasUpdater.OnValidate();

			}

			if (this.canvasScaler == null || this.GetComponents<CanvasScaler>().Length > 1) {

				if (this.GetComponent<CanvasScaler>() != null) Component.DestroyImmediate(this.GetComponent<CanvasScaler>());
				this.canvasScaler = this.GetComponent<CanvasScaler>();
				if (this.canvasScaler == null) this.canvasScaler = this.gameObject.AddComponent<CanvasScaler>();

			}

			var rectTransform = (this.transform as RectTransform);
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.pivot = Vector2.one * 0.5f;
			rectTransform.localScale = Vector3.one;
			rectTransform.localRotation = Quaternion.identity;
			rectTransform.anchoredPosition3D = Vector3.zero;

		}
Пример #2
0
 public void OnUpdate()
 {
     CanvasUpdater.ForceUpdate(this.canvas, this.canvasScaler);
 }