/// <summary> /// Don't touch it!! /// </summary> public void TermPlugin() { StopNetwork(); //Debug.Log("EffekseerSystem.TermPlugin"); foreach (var effectAsset in EffekseerEffectAsset.enabledAssets) { EffekseerEffectAsset target = effectAsset.Value.Target as EffekseerEffectAsset; if (target != null) { ReleaseEffect(target); } } nativeEffects.Clear(); #if UNITY_EDITOR nativeEffectsKeys.Clear(); nativeEffectsValues.Clear(); #endif // Finalize Effekseer library Plugin.EffekseerTerm(); // For a platform that is releasing in render thread GL.IssuePluginEvent(Plugin.EffekseerGetRenderFunc(), 0); Instance = null; }
private void ReloadEffects() { foreach (var weakEffectAsset in EffekseerEffectAsset.enabledAssets) { EffekseerEffectAsset effectAsset = weakEffectAsset.Value.Target as EffekseerEffectAsset; if (effectAsset != null) { effectAssetInLoading = effectAsset; int id = effectAsset.GetInstanceID(); IntPtr nativeEffect; if (nativeEffects.TryGetValue(id, out nativeEffect)) { Plugin.EffekseerReloadResources(nativeEffect); } effectAssetInLoading = null; } } /* * foreach (var effectAsset in loadedEffects) { * effectAssetInLoading = effectAsset; * int id = effectAsset.GetInstanceID(); * IntPtr nativeEffect; * if (nativeEffects.TryGetValue(id, out nativeEffect)) { * Plugin.EffekseerReloadResources(nativeEffect); * } * effectAssetInLoading = null; * } */ }
/// <summary xml:lang="en"> /// Plays the effect. /// <param name="name">Effect name</param> /// </summary> /// <summary xml:lang="ja"> /// エフェクトを再生 /// <param name="name">エフェクト名</param> /// </summary> public EffekseerHandle Play(EffekseerEffectAsset effectAsset) { var h = EffekseerSystem.PlayEffect(effectAsset, transform.position); // must run after loading cachedMagnification = effectAsset.Magnification; h.SetRotation(transform.rotation); h.SetScale(transform.localScale); h.layer = gameObject.layer; if (speed != 1.0f) { h.speed = speed; } if (paused) { h.paused = paused; } if (shown) { h.shown = shown; } handles.Add(h); return(h); }
/// <summary xml:lang="en"> /// Plays the effect. /// </summary> /// <param name="effectAsset" xml:lang="en">Effect asset</param> /// <param name="location" xml:lang="en">Location in world space</param> /// <returns>Played effect instance</returns> /// <summary xml:lang="ja"> /// エフェクトの再生 /// </summary> /// <param name="effectAsset" xml:lang="ja">エフェクトアセット</param> /// <param name="location" xml:lang="ja">再生開始する位置</param> /// <returns>再生したエフェクトインスタンス</returns> public static EffekseerHandle PlayEffect(EffekseerEffectAsset effectAsset, Vector3 location) { if (Instance == null) { #if UNITY_EDITOR if (Application.isPlaying) { Debug.LogError("[Effekseer] System is not initialized."); } else { Debug.LogError("[Effekseer] System is not initialized. Please call EffekseerEditor.instance.InitSystem"); } #else Debug.LogError("[Effekseer] System is not initialized."); #endif return(new EffekseerHandle(-1)); } if (effectAsset == null) { Debug.LogError("[Effekseer] Specified effect is null."); return(new EffekseerHandle(-1)); } IntPtr nativeEffect; if (Instance.nativeEffects.TryGetValue(effectAsset.GetInstanceID(), out nativeEffect)) { int handle = Plugin.EffekseerPlayEffect(nativeEffect, location.x, location.y, location.z); return(new EffekseerHandle(handle)); } return(new EffekseerHandle(-1)); }
internal float GetEffectMagnification(EffekseerEffectAsset effectAsset) { int id = effectAsset.GetInstanceID(); IntPtr nativeEffect; if (nativeEffects.TryGetValue(id, out nativeEffect)) { return(Plugin.EffekseerGetEffectMagnification(nativeEffect)); } return(0.0f); }
internal void ReleaseEffect(EffekseerEffectAsset effectAsset) { int id = effectAsset.GetInstanceID(); IntPtr nativeEffect; if (nativeEffects.TryGetValue(id, out nativeEffect)) { Plugin.EffekseerReleaseEffect(nativeEffect); nativeEffects.Remove(id); //loadedEffects.Remove(effectAsset); } }
void OnEnable() { system.OnEnable(); soundPlayer.OnEnable(); foreach (var effectAsset in EffekseerEffectAsset.enabledAssets) { EffekseerEffectAsset target = effectAsset.Value.Target as EffekseerEffectAsset; if (target != null) { EffekseerSystem.Instance.LoadEffect(target); } } }
public void LoadEffect() { if (EffekseerSystem.IsValid) { EffekseerSystem.Instance.LoadEffect(this); } while (true) { dictionaryKey = keyGenerator.Next(); if (!enabledAssets.ContainsKey(dictionaryKey)) { enabledAssets.Add(dictionaryKey, new WeakReference(this)); break; } } gcCounter++; // GC if (gcCounter > 20) { removingTargets.Clear(); foreach (var kv in enabledAssets) { EffekseerEffectAsset target = kv.Value.Target as EffekseerEffectAsset; if (target == null) { removingTargets.Add(kv.Key); } } foreach (var k in removingTargets) { enabledAssets.Remove(k); } gcCounter = 0; } }
/// <summary xml:lang="en"> /// Plays the effect. /// </summary> /// <param name="effectAsset" xml:lang="en">Effect asset</param> /// <param name="location" xml:lang="en">Location in world space</param> /// <returns>Played effect instance</returns> /// <summary xml:lang="ja"> /// エフェクトの再生 /// </summary> /// <param name="effectAsset" xml:lang="ja">エフェクトアセット</param> /// <param name="location" xml:lang="ja">再生開始する位置</param> /// <returns>再生したエフェクトインスタンス</returns> public static EffekseerHandle PlayEffect(EffekseerEffectAsset effectAsset, Vector3 location) { if (Instance == null) { Debug.LogError("[Effekseer] System is not initialized."); return(new EffekseerHandle(-1)); } if (effectAsset == null) { Debug.LogError("[Effekseer] Specified effect is null."); return(new EffekseerHandle(-1)); } IntPtr nativeEffect; if (Instance.nativeEffects.TryGetValue(effectAsset.GetInstanceID(), out nativeEffect)) { int handle = Plugin.EffekseerPlayEffect(nativeEffect, location.x, location.y, location.z); return(new EffekseerHandle(handle)); } return(new EffekseerHandle(-1)); }
/// <summary> /// Don't touch it!! /// </summary> public void LoadEffect(EffekseerEffectAsset effectAsset) { effectAssetInLoading = effectAsset; int id = effectAsset.GetInstanceID(); IntPtr nativeEffect; if (!nativeEffects.TryGetValue(id, out nativeEffect)) { byte[] bytes = effectAsset.efkBytes; var namePtr = Marshal.StringToCoTaskMemUni(effectAsset.name); nativeEffect = Plugin.EffekseerLoadEffectOnMemory(bytes, bytes.Length, namePtr, effectAsset.Scale); nativeEffects.Add(id, nativeEffect); //loadedEffects.Add(effectAsset); //effectAsset.GetInstanceID Marshal.FreeCoTaskMem(namePtr); } else { // For reloading Plugin.EffekseerReloadResources(nativeEffect); } effectAssetInLoading = null; }