コード例 #1
0
        protected AudioClip Load(string fileName, string RootPath)
        {
            if (this._Audioes != null)
            {
                if (_Audioes.ContainsKey(fileName))
                {
                    var clip = _Audioes[fileName] ?? Modeling.LoadResource <AudioClip>(RootPath + fileName);

#if UNITY_EDITOR
                    //if (clip == null)
                    //   Debug.LogError("Mising audioclupo + " + fileName);
#endif

                    _Audioes.TryAdd(fileName, clip);
                    return(clip);
                }
                else
                {
                    var clip = Modeling.LoadResource <AudioClip>(RootPath + fileName);
#if UNITY_EDITOR
                    //if (clip == null)
                    //    Debug.LogError("Mising audioclupo + " + fileName);
#endif
                    _Audioes.TryAdd(fileName, clip);
                    return(clip);
                }
            }

#if UNITY_EDITOR
            //Debug.LogError("Mising audioclupo + " + fileName);
#endif
            return(null);
        }
コード例 #2
0
 /// <summary>
 /// Creates and initializes the audiosource component with the appropriate values
 /// </summary>
 public virtual void Create()
 {
     _AudioSource          = Modeling.LoadResource <AudioSource>(this.Path) as AudioSource;
     _AudioSource.clip     = this.Clip;
     _AudioSource.loop     = this.Loop;
     _AudioSource.mute     = this.Mute;
     _AudioSource.volume   = this.Volume;
     _AudioSource.priority = this.Priority;
     _AudioSource.pitch    = this.Pitch;
 }
コード例 #3
0
    public T Load <T>(string Path, bool IsIMMEDIATE = false) where T : UnityEngine.Object
    {
        if (this.Cache == null)
        {
            this.Cache = new Dictionary <string, Object>();
        }

        Object Obj = null;

        // Cái TryGetValue sẽ tự Add Key luôn.
        if (this.Cache.TryGetValue(Path, out Obj))
        {
            if (Obj == null)
            {
                Debug.LogError("34567i9o0");
                // Nếu chưa Loadxong mà Return ngay lúc dó thì sao ?
                /* return Async.asset as GameObject; */
                if (IsIMMEDIATE == false)
                {
                    ResourceRequest Async = Loader(Path);
                    Async.completed += async =>
                    {
                        this.Cache[Path] = Async.asset;
                        // Chổ này cái Obj bị hủy thì có tính là Null không ta ?
                        // À. Nó tính là Null nè;
                        if (Obj != null)
                        {
                            Obj = Async.asset;
                        }
                    };
                    return(Async.asset as T);
                }
                // Vậy nếu cần ngay thì sao ?!.
                // Chuyển sang Load ngay lập tức và Return luôn
                else
                {
                    Obj = Modeling.LoadResource <T>(Path);
                    this.Cache.Add(Path, Obj);
                    return(Obj as T);
                }
            }
        }
        else
        {
            //
            Debug.LogError("34567i9o0");
            // Nếu chưa Loadxong mà Return ngay lúc dó thì sao ?
            /* return Async.asset as GameObject; */
            if (IsIMMEDIATE == false)
            {
                ResourceRequest Async = Loader(Path);
                Async.completed += async =>
                {
                    this.Cache[Path] = Async.asset;
                    // Chổ này cái Obj bị hủy thì có tính là Null không ta ?
                    // À. Nó tính là Null nè;
                    if (Obj != null)
                    {
                        Obj = Async.asset;
                    }
                };
                return(Async.asset as T);
            }
            // Vậy nếu cần ngay thì sao ?!.
            // Chuyển sang Load ngay lập tức và Return luôn
            else
            {
                Obj = Modeling.LoadResource <T>(Path);
                this.Cache.Add(Path, Obj);
                return(Obj as T);
            }
        }


        return(Obj as T);
    }
コード例 #4
0
 protected virtual AudioClip LoadSfx(string path, string fileExt)
 {
     return(Modeling.LoadResource <AudioClip>(path));
 }