| | |
| | | using System; |
| | | using Spine.Unity; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class UIHeroController : MonoBehaviour |
| | | { |
| | |
| | | } |
| | | |
| | | skinID = _skinID; |
| | | var skinConfig = HeroSkinConfig.Get(skinID); |
| | | if (isLh) |
| | | { |
| | | |
| | | //X轴偏移,Y轴偏移,缩放,是否水平翻转(0否1是) |
| | | if (skinConfig.TachieParam.Length == 4) |
| | | { |
| | | this.transform.localPosition = new Vector3(skinConfig.TachieParam[0], skinConfig.TachieParam[1], 0); |
| | | this.transform.localScale = Vector3.one * skinConfig.TachieParam[2]; |
| | | this.transform.localRotation = Quaternion.Euler(0, skinConfig.TachieParam[3] == 0 ? 0 : 180, 0); |
| | | } |
| | | else |
| | | { |
| | | this.transform.localPosition = Vector3.zero; |
| | | this.transform.localScale = Vector3.one; |
| | | this.transform.localRotation = Quaternion.identity; |
| | | } |
| | | |
| | | //立绘特殊处理,没有spine动画的改用图片 |
| | | var lhImg = this.AddMissingComponent<RawImage>(); |
| | | if (!skinConfig.Tachie.Contains("SkeletonData")) |
| | | { |
| | | //图片替换 |
| | | lhImg.SetTexture2DPNG(skinConfig.Tachie); |
| | | lhImg.SetNativeSize(); |
| | | if (skeletonGraphic != null) |
| | | { |
| | | skeletonGraphic.enabled = false; |
| | | } |
| | | lhImg.enabled = true; |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | if (skeletonGraphic != null) |
| | | { |
| | | skeletonGraphic.enabled = true; |
| | | } |
| | | lhImg.enabled = false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | this.transform.localScale = Vector3.one * scale; |
| | | } |
| | | |
| | | onComplete = _onComplete; |
| | | pool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("UIHero")); |
| | | |
| | |
| | | } |
| | | |
| | | skeletonGraphic = instanceGO.GetComponentInChildren<SkeletonGraphic>(true); |
| | | var skinConfig = HeroSkinConfig.Get(skinID); |
| | | if (isLh) |
| | | { |
| | | skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinConfig.Tachie); |
| | | } |
| | | else |
| | | { |
| | | { |
| | | skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinConfig.SpineRes); |
| | | } |
| | | if (skeletonGraphic.skeletonDataAsset == null) |
| | |
| | | return; |
| | | } |
| | | skeletonGraphic.Initialize(true); |
| | | if (isLh) |
| | | { |
| | | //X轴偏移,Y轴偏移,缩放,是否水平翻转(0否1是) |
| | | if (skinConfig.TachieParam.Length == 4) |
| | | { |
| | | this.transform.localPosition = new Vector3(skinConfig.TachieParam[0], skinConfig.TachieParam[1], 0); |
| | | this.transform.localScale = Vector3.one * skinConfig.TachieParam[2]; |
| | | this.transform.localRotation = Quaternion.Euler(0, skinConfig.TachieParam[3] == 0 ? 0 : 180, 0); |
| | | } |
| | | else |
| | | { |
| | | this.transform.localPosition = Vector3.zero; |
| | | this.transform.localScale = Vector3.one; |
| | | this.transform.localRotation = Quaternion.identity; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | this.transform.localScale = Vector3.one * scale; |
| | | } |
| | | |
| | | spineAnimationState = skeletonGraphic.AnimationState; |
| | | spineAnimationState.Data.DefaultMix = 0f; |
| | | if (motionName == "") |