| | |
| | | using System.IO; |
| | | using UnityEngine.Video; |
| | | using Spine.Unity; |
| | | using UnityEngine.UI; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | #endif |
| | | |
| | | public T LoadAsset<T> (string directory, string name) where T : UnityEngine.Object |
| | | public T LoadAsset<T> (string directory, string name, bool needExt = true) where T : UnityEngine.Object |
| | | { |
| | | T asset = null; |
| | | // 特殊处理 因为有一层图集的关系 directory要传入的应该是atlas的名字 |
| | |
| | | directory = directory.Replace("\\", "/"); |
| | | } |
| | | |
| | | return LoadAssetInternal<T>(directory, name); |
| | | return LoadAssetInternal<T>(directory, name, needExt); |
| | | } |
| | | |
| | | private T LoadAssetInternal<T>(string directory, string name) where T : UnityEngine.Object |
| | | private T LoadAssetInternal<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object |
| | | { |
| | | T asset = null; |
| | | var path = ($"Assets/ResourcesOut/{directory}/{name}" + (needExt ? GetExtension(typeof(T)) : "")).Replace("//", "/").Trim().Replace("\\", "/"); |
| | | |
| | | var path = ($"Assets/ResourcesOut/{directory}/{name}" + GetExtension(typeof(T))).Replace("//", "/").Trim().Replace("\\", "/"); |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | #if UNITY_EDITOR |
| | |
| | | return LoadAssetInternal<Sprite>(atlasName, spriteName); |
| | | } |
| | | |
| | | public void LoadAssetAsync<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object |
| | | public void LoadAssetAsync<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack, bool needExt = true) where T : UnityEngine.Object |
| | | { |
| | | // 特殊处理 因为有一层图集的关系 directory要传入的应该是atlas的名字 |
| | | if (typeof(T) == typeof(Sprite)) |
| | |
| | | return; |
| | | } |
| | | |
| | | LoadAssetAsyncInternal<T>(directory, name, callBack); |
| | | LoadAssetAsyncInternal<T>(directory, name, callBack, needExt); |
| | | } |
| | | |
| | | private void LoadSpriteAsync<T>(string atlasName, string spriteName, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object |
| | |
| | | #endif |
| | | } |
| | | |
| | | private void LoadAssetAsyncInternal<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object |
| | | private void LoadAssetAsyncInternal<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack, bool needExt = true) where T : UnityEngine.Object |
| | | { |
| | | var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T))).Replace("//", "/"); |
| | | var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", (needExt ? GetExtension(typeof(T)) : "")).Replace("//", "/"); |
| | | |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | |
| | | { |
| | | ResManager.Instance.UnloadAsset(ResourcesPath.UI_FONT_SUFFIX, _fontName); |
| | | } |
| | | |
| | | |
| | | public static Texture2D LoadTexture2D(string _iconKey) |
| | | { |
| | | var iconConfig = IconConfig.Get(_iconKey); |
| | |
| | | } |
| | | return ResManager.Instance.LoadAsset<Texture2D>(StringUtility.Contact(ResourcesPath.UI_TEXTURE_SUFFIX, "/" + iconConfig.folder), iconConfig.sprite); |
| | | } |
| | | |
| | | public static Texture2D LoadTexture2DPNG(string name) |
| | | { |
| | | return ResManager.Instance.LoadAsset<Texture2D>(StringUtility.Contact(ResourcesPath.UI_TEXTURE_SUFFIX, "/FullScreenBg"), name + ".png", false); |
| | | } |
| | | } |
| | |
| | | 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 == "") |
| | |
| | | var texture = UILoader.LoadTexture2D(_id); |
| | | _image.texture = texture; |
| | | } |
| | | |
| | | |
| | | public static void SetTexture2DPNG(this RawImage _image, string _id) |
| | | { |
| | | if (_image == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var texture = UILoader.LoadTexture2DPNG(_id); |
| | | _image.texture = texture; |
| | | } |
| | | } |