public override void EditorSave() { base.EditorSave(); UIDeviceType deviceType = UILayoutManager.DeviceType; if (deviceType != UIDeviceType.Phone) { if (deviceType == UIDeviceType.Tablet) { UIDeviceOrientation orientation = UILayoutManager.Orientation; if (orientation != UIDeviceOrientation.Portrait) { if (orientation == UIDeviceOrientation.LandscapeRight || orientation == UIDeviceOrientation.LandscapeLeft) { if (this.tabletLandscape == null) { this.tabletLandscape = new UICanvasScalerData(); } this.tabletLandscape = UICanvasScalerData.FromCanvas(this.transform); } } else { if (this.tabletPortrait == null) { this.tabletPortrait = new UICanvasScalerData(); } this.tabletPortrait = UICanvasScalerData.FromCanvas(this.transform); } } } else { switch (UILayoutManager.Orientation) { case UIDeviceOrientation.Portrait: case UIDeviceOrientation.PortraitUpsideDown: if (this.phonePortrait == null) { this.phonePortrait = new UICanvasScalerData(); } this.phonePortrait = UICanvasScalerData.FromCanvas(this.transform); break; case UIDeviceOrientation.LandscapeRight: case UIDeviceOrientation.LandscapeLeft: if (this.phoneLandscape == null) { this.phoneLandscape = new UICanvasScalerData(); } this.phoneLandscape = UICanvasScalerData.FromCanvas(this.transform); break; } } }
private void ApplyScaler(UICanvasScalerData scaler) { if (scaler == null || !scaler.hasData) { return; } CanvasScaler component = base.GetComponent <CanvasScaler>(); component.referenceResolution = scaler.referenceResolution; component.matchWidthOrHeight = scaler.matchWidthOrHeight; }