コード例 #1
0
        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;
             * }
             */
        }
コード例 #2
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)
            {
#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));
        }
コード例 #3
0
        internal float GetEffectMagnification(EffekseerEffectAsset effectAsset)
        {
            int    id = effectAsset.GetInstanceID();
            IntPtr nativeEffect;

            if (nativeEffects.TryGetValue(id, out nativeEffect))
            {
                return(Plugin.EffekseerGetEffectMagnification(nativeEffect));
            }
            return(0.0f);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
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));
        }
コード例 #6
0
        /// <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;
        }