public static void PlaySkeletonSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <SkeletonSfx> Callback, bool IsLoop = false, string AnimationName = "", LiteAction Finished = null) { if (Parent == null || Uri == null) { return; } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } AssetManager.CreatePrefabAsync(Uri, (Obj) => { var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Position; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); Callback?.Invoke(Sfx); }); }
public static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, string AnimationName = "", LiteAction Finished = null) { if (Parent == null || Uri == null) { return(null); } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Position ?? Vector2.zero; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); return(Sfx); }
public static BaseCfg <T> Parse <T>(AssetUri Uri) where T : IBaseCfgLine, new() { if (!DataManager.LoadSync(Uri)) { throw new LiteException($"can't get data table : {Uri}"); } return(Parse <T>(Uri.AssetName)); }
public void AssertUriCompare() { var a = new AssetUri("module:type:name1"); var b = new AssetUri("module:type:name2"); Assert.IsTrue(b.CompareTo(a) > 0); Assert.IsTrue(a.CompareTo(b) < 0); Assert.IsTrue(a.CompareTo(a) == 0); Assert.IsTrue(b.CompareTo(b) == 0); }
public static uint PlayMusic(AssetUri Uri, bool IsLoop = true, float Volume = 1.0f, bool IsOnly = true) { if (IsOnly) { StopAllMusic(); } return(PlayAudio(AudioType.Music, Root_, Uri, IsLoop, Volume)); }
public void AssetUriIsValid() { var uri = new AssetUri("module:type:name"); Assert.AreEqual(true, uri.IsValid); Assert.AreEqual("module", uri.Module); Assert.AreEqual("type", uri.Type); Assert.AreEqual("name", uri.Name); Assert.AreEqual("module:type:name", uri.FullName); Assert.AreEqual("module:type:name".GetHashCode(), uri.GetHashCode()); }
public static void AddClickEvent(Transform Obj, UnityAction Callback, AssetUri AudioUri) { void OnClick() { AudioManager.PlaySound(AudioUri); Callback?.Invoke(); } AddEvent(Obj, OnClick); }
public void AssertUriOperators() { var a = new AssetUri("module:type:name"); var b = new AssetUri("module:type:name"); Assert.IsTrue(a == b); Assert.IsFalse(a != b); Assert.IsTrue(a == "module:type:name"); Assert.IsTrue("module:type:name" == a); Assert.IsTrue(a.Equals(b)); Assert.IsTrue(a.Equals((object)b)); }
private static uint PlayAudio(AudioType Type, Transform Parent, AssetUri Uri, bool IsLoop = false, float Volume = 1.0f) { if (Uri == null) { return(0); } var Entity = new AudioEntity(Type); AudioList_.Add(Entity.SerialID, Entity); AssetManager.CreateAssetAsync <AudioClip>(Uri, (Clip) => { if (Clip == null) { LLogger.LWarning($"can't play audio : {Uri}"); RemoveList_.Add(Entity); return; } Entity.LoadAudio(Parent, Clip, IsLoop, Volume, false); switch (Type) { case AudioType.Sound: if (MuteSound) { Entity.Mute(MuteSound); } break; case AudioType.Music: if (MuteMusic) { Entity.Mute(MuteMusic); } break; default: break; } Entity.Play(); }); return(Entity.SerialID); }
public static void ReplaceSprite(SpriteRenderer Master, AssetUri Uri) { if (Master == null || Uri == null) { return; } AssetManager.CreateAssetAsync <Sprite>(Uri, (Spr) => { if (Spr == null) { LLogger.LWarning($"can't load {Uri}"); return; } Master.sprite = Spr; }); }
public static void LoadAsync(AssetUri Uri, LiteAction <bool> Callback) { if (!DataList_.ContainsKey(Uri.AssetName)) { AssetManager.CreateDataAsync(Uri, Buffer => { var Data = new DataTable(Uri.AssetName); var Succeeded = Data.Parse(Buffer); if (Succeeded) { DataList_.Add(Uri.AssetName, Data); } Callback?.Invoke(Succeeded); }); } }
public static bool LoadSync(AssetUri Uri) { if (!DataList_.ContainsKey(Uri.AssetName)) { var Buffer = AssetManager.CreateDataSync(Uri); var Data = new DataTable(Uri.AssetName); var Succeeded = Data.Parse(Buffer); if (Succeeded) { DataList_.Add(Uri.AssetName, Data); } return(Succeeded); } return(true); }
public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <ParticleSfx> Callback, bool IsLoop = false, LiteAction Finished = null) { if (Parent == null || Uri == null) { return; } AssetManager.CreatePrefabAsync(Uri, (Obj) => { var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(string.Empty, IsLoop, Finished); Sfx.Position = Position; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); Callback?.Invoke(Sfx); }); }
public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, LiteAction Finished = null) { if (Parent == null || Uri == null) { return(null); } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(string.Empty, IsLoop, Finished); Sfx.Position = Position ?? Vector2.zero; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); return(Sfx); }
public static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, string AnimationName = "", bool IsLoop = false, Action Finished = null) { if (Parent == null || Uri == null) { return(null); } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Vector2.zero; return(Sfx); }
public override string ToString() { AssetUri prefabUri = PrefabURI; StringBuilder builder = new StringBuilder(); builder.Append("EntityRef{id = "); builder.Append(Id); NetworkComponent networkComponent = getComponent(typeof(NetworkComponent)); if (networkComponent != null) { builder.Append(", netId = "); builder.Append(networkComponent.NetworkId); } if (prefabUri != null) { builder.Append(", prefab = '"); builder.Append(prefabUri.toSimpleString()); builder.Append("'"); } builder.Append("}"); return(builder.ToString()); }
public static void ReplaceSprite(Image Master, bool IsNativeSize, AssetUri Uri) { if (Master == null || Uri == null) { return; } AssetManager.CreateAssetAsync <Sprite>(Uri, (Spr) => { if (Spr == null) { LLogger.LWarning($"can't load {Uri}"); return; } Master.sprite = Spr; if (IsNativeSize) { Master.SetNativeSize(); } }); }
public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Action Finished = null) { if (Parent == null || Uri == null) { return(null); } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(string.Empty, IsLoop, Finished); Sfx.Position = Vector2.zero; var Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent); if (Canvas != null && Canvas.overrideSorting) { UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1); } return(Sfx); }
public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, Action <ParticleSfx> Callback, bool IsLoop = false, Action Finished = null) { if (Parent == null || Uri == null) { return; } AssetManager.CreatePrefabAsync(Uri, (Obj) => { var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(string.Empty, IsLoop, Finished); Sfx.Position = Position; var Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent); if (Canvas != null && Canvas.overrideSorting) { UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1); } Callback?.Invoke(Sfx); }); }
public void ReplaceSprite(string ChildPath, bool IsNativeSize, AssetUri Uri) { UIHelper.ReplaceSprite(GetComponent <Image>(ChildPath), IsNativeSize, Uri); }
public void AddClickEventToChild(string ChildPath, UnityAction Callback, AssetUri AudioUri) { UIHelper.AddClickEventToChild(UITransform, ChildPath, Callback, AudioUri); }
public void AddClickEventToChild(string ChildPath, LiteAction <EventSystemData> Callback, AssetUri AudioUri) { UIHelper.AddClickEventToChild(UITransform, ChildPath, Callback, AudioUri); }
public void AddClickEvent(UnityAction Callback, AssetUri AudioUri) { UIHelper.AddClickEvent(UITransform, Callback, AudioUri); }
public UIDescriptor(AssetUri Uri, bool OpenMore, bool Cached) { this.Uri = Uri; this.OpenMore = OpenMore; this.Cached = Cached; }
public static uint PlaySound(AssetUri Uri, bool IsLoop = false, float Volume = 1.0f) { return(PlayAudio(AudioType.Sound, Root_, Uri, IsLoop, Volume)); }
public OpenTKMesh(AssetUri uri, MeshData data) : base(uri) { reload(data); }
public static void AddClickEventToChild(Transform Parent, string ChildPath, UnityAction Callback, AssetUri AudioUri) { void OnClick() { AudioManager.PlaySound(AudioUri); Callback?.Invoke(); } AddEventToChild(Parent, ChildPath, OnClick); }
public static void AddClickEventToChild(GameEntity Entity, string ChildPath, UnityAction Callback, AssetUri AudioUri) { AddClickEventToChild(Entity?.GetTransform(), ChildPath, Callback, AudioUri); }
public PojoPrefab(AssetUri uri, PrefabData data) : base(uri) { reload(data); }
public static void AddClickEvent(GameEntity Entity, UnityAction Callback, AssetUri AudioUri) { AddClickEvent(Entity?.GetTransform(), Callback, AudioUri); }
public Prefab(AssetUri uri) : base(uri) { }
public static void AddClickEventToChild(Transform Parent, string ChildPath, LiteAction <EventSystemData> Callback, AssetUri AudioUri) { void OnClick(EventSystemData Data) { AudioManager.PlaySound(AudioUri); Callback?.Invoke(Data); } AddEventToChild(Parent, ChildPath, OnClick); }