12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using UnityEngine;
- namespace ET.Client
- {
- [FriendOf(typeof(ResourcesComponentHelper))]
- public static class ResourcesComponentHelperSystem
- {
- [ObjectSystem]
- public class ResourcesComponentHelperAwakeSystem : AwakeSystem<ResourcesComponentHelper>
- {
- protected override void Awake(ResourcesComponentHelper self)
- {
- ResourcesComponentHelper.Instance = self;
- }
- }
-
- [ObjectSystem]
- public class ResourcesComponentHelperDestroySystem : DestroySystem<ResourcesComponentHelper>
- {
- protected override void Destroy(ResourcesComponentHelper self)
- {
- ResourcesComponentHelper.Instance = null;
-
- }
- }
- public static async ETTask LoadSprite(this ResourcesComponentHelper self,Scene scene,string ab)
- {
- await scene.GetComponent<ResourcesLoaderComponent>().LoadAsync(ab.StringToAB());
- }
- public static Sprite GetSprite(this ResourcesComponentHelper self,string ab, string spriteName)
- {
- UnityEngine.Object spriteObj = ResourcesComponent.Instance.GetAsset(ab.StringToAB(), spriteName);
- if (spriteObj != null)
- {
- Texture2D texture = spriteObj as Texture2D;
- var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100f);
- return sprite;
- }
- return null;
- }
- }
- [ComponentOf(typeof(Scene))]
- public class ResourcesComponentHelper : Entity, IAwake, IDestroy
- {
- public static ResourcesComponentHelper Instance { get; set; }
-
- }
- }
|