Beispiel #1
0
        void RunScript(string file)
        {
            Log.i("runScript path=" + file, Log.Tag.Sitcom);
            if (string.IsNullOrEmpty(file))
            {
                Log.e("sitcom table error sitcomid=" + mSitcomId, Log.Tag.Sitcom);
                return;
            }

            using (ResLoad ld = ResLoad.get(file))
            {
                RunScript(ld.asset <TextAsset> ());
            }
        }
Beispiel #2
0
 public static bool setImage(Image image, string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         return(false);
     }
     using (ResLoad rl = ResLoad.get(path))
     {
         if (null == rl.asset <GameObject>())
         {
             return(false);
         }
         return(setImage(image, rl));
     }
 }
Beispiel #3
0
        public Audio Play(int soundId, GameObject source, SwitchType switchType = SwitchType.Fade, string tag = null)
        {
            if (soundId == 0)
            {
                return(null);
            }

            // 背景音乐关闭
            if (soundId <= 100 && false == mMusicOn)
            {
                return(null);
            }

            // 音效关闭
            if (soundId > 100 && false == mEffectOn)
            {
                return(null);
            }

            //该背景音乐正在播放
            if (soundId <= 100 && mCurMusic != null && mCurMusic.tb.id == soundId)
            {
                return(mCurMusic);
            }

            TBSound tb = TableMgr.single.GetDataByKey(typeof(TBSound), soundId) as TBSound;

            if (null == tb)
            {
                return(null);
            }
            GameObject src;

            if (source == null)
            {//2d声音/
                src = new GameObject(soundId.ToString());
                if (tag != null)
                {
                    src.tag = tag;
                }
                src.transform.parent        = transform;
                src.transform.localPosition = Vector3.zero;
            }
            else
            {
                src = new GameObject(soundId.ToString());
                if (tag != null)
                {
                    src.tag = tag;
                }
                src.transform.parent        = source.transform;
                src.transform.localPosition = Vector3.zero;
            }

            Audio audio = new Audio();

            audio.switchType = switchType;
            audio.tb         = tb;
            audio.trans      = src.transform;
            audio.state      = StateType.Waitting;
            if (tb.id <= 100)
            {
                if (mCurMusic != null)
                {
                    mCurMusic.Stop();
                }
                mCurMusic   = audio;
                mCurMusicId = soundId;
            }

            //异步的引用计数会出错,可能src对象销毁了asset才加载进来
            ResLoad rl = ResLoad.get(tb.asset, ResideType.Ref);

            src.AddComponent <AudioRef>().resLoad = rl;
            OnLoadAssetFinish(rl.asset <AudioClip>(), src, audio, null);
            return(audio);
        }