public override void EditorSave() { base.EditorSave(); UIDeviceType deviceType = UILayoutManager.DeviceType; if (deviceType != UIDeviceType.Phone) { if (deviceType == UIDeviceType.Tablet) { switch (UILayoutManager.Orientation) { case UIDeviceOrientation.Portrait: case UIDeviceOrientation.PortraitUpsideDown: if (this.tabletPortrait == null) { this.tabletPortrait = new UISpriteSwapnData(); } this.tabletPortrait = UISpriteSwapnData.FromSpriteIndex(this.GetSpriteIndex()); break; case UIDeviceOrientation.LandscapeRight: case UIDeviceOrientation.LandscapeLeft: if (this.tabletLandscape == null) { this.tabletLandscape = new UISpriteSwapnData(); } this.tabletLandscape = UISpriteSwapnData.FromSpriteIndex(this.GetSpriteIndex()); break; } } } else { switch (UILayoutManager.Orientation) { case UIDeviceOrientation.Portrait: case UIDeviceOrientation.PortraitUpsideDown: if (this.phonePortrait == null) { this.phonePortrait = new UISpriteSwapnData(); } this.phonePortrait = UISpriteSwapnData.FromSpriteIndex(this.GetSpriteIndex()); break; case UIDeviceOrientation.LandscapeRight: case UIDeviceOrientation.LandscapeLeft: if (this.phoneLandscape == null) { this.phoneLandscape = new UISpriteSwapnData(); } this.phoneLandscape = UISpriteSwapnData.FromSpriteIndex(this.GetSpriteIndex()); break; } } }
private void ApplySprite(UISpriteSwapnData spriteData) { if (spriteData == null || !spriteData.hasData) { return; } if (spriteData.spriteIndex < this.sprites.Length && spriteData.spriteIndex >= 0) { this.Image.sprite = this.sprites[spriteData.spriteIndex]; } else { UnityEngine.Debug.LogError("UISpriteSwapError. " + base.gameObject.name); } }