Esempio n. 1
0
        //load asset in editor mode,directly from the assetdatabase
#if UNITY_EDITOR
        private IEnumerator load_asset_from_assetdatabase(string _asset_path, Type _type, AssetResource _result, bool _lock_asset = true, bool _scene_asset = false, string _scene_name = "")
        {
            yield return(null);//force wait one frame to simulate the async logic

            UnityEngine.Object loaded_asset = null;
            if (_scene_asset)
            {
                // Temp Test Quad Tree Scene
//                 if(_scene_name == "X4_zhucheng_001")
//                 {
//                     _scene_name = "daditu_001";
//                 }

                //Test End

                //load level
                sceneLoadAsyncOp = SceneManager.LoadSceneAsync(_scene_name);
                yield return(sceneLoadAsyncOp);
            }
            else
            {
                //loaded_asset = Resources.Load(_asset_path, _type);
                loaded_asset = EditorResourceLoader.LoadAssetAtPath(_asset_path, _type);
                if (loaded_asset == null)
                {
                    Debug.LogError(string.Format("asset counld not be loaded {0},check xls or your project", _asset_path));
                    yield break;
                }
            }
            //create the assetobject
            AssetObject ao = _scene_asset ? new SceneAssetObject(_asset_path) : new AssetObject(_asset_path, loaded_asset);

            assetobj_cache_.put_to_cache(_asset_path, ao);
            _result.set_obj(ao);
        }
Esempio n. 2
0
        private void LoadDocCommands()
        {
#if UNITY_EDITOR
            TextAsset textObj = EditorResourceLoader.LoadAssetAtPath("Assets/Res/DB/debug_command.csv", typeof(TextAsset)) as TextAsset;

            if (textObj != null)
            {
                string strData = xc.CommonTool.BytesToUtf8(textObj.bytes);

                if (!string.IsNullOrEmpty(strData))
                {
                    csv.Table table = new csv.Table();
                    table.InitFromString(strData);

                    for (int i = 0; i < table.Count; i++)
                    {
                        List <CommandInfo> list = DebugCommandConfig.COMMAND_LIST;

                        string id      = table.Select(i, "id");
                        string name    = table.Select(i, "name");
                        string command = table.Select(i, "doc_command");

                        string doc_name = "doc_" + id;
                        var    info     = new CommandInfo(doc_name, name, DebugCommandConfig.OnDefaultCommandProcessor, null, true, command);

                        list.Add(info);
                    }
                }
            }
#endif
        }
Esempio n. 3
0
        public static IEnumerator LoadDll()
        {
            var assetPath = "Assets/Res/DB/Common/hotdll.bytes";

            UnityEngine.Object loadedAsset = null;
#if UNITY_EDITOR
            loadedAsset = EditorResourceLoader.LoadAssetAtPath(assetPath, typeof(TextAsset));
            if (loadedAsset == null)
            {
                Debug.LogError(string.Format("asset counld not be loaded {0},check xls or your project", assetPath));
                yield break;
            }
#else
            var bundle_url = GetBundleURL(assetPath);
            bundle_url = CommonTool.WipeFileSprit(bundle_url);

            var requeset = AssetBundle.LoadFromFileAsync(bundle_url);
            yield return(requeset);

            var bundle = requeset.assetBundle;
            if (bundle == null)
            {
                Debug.LogError(string.Format("[ResourceLoader](load_bundle_from_disk_coroutine)load bundle rfrom www failed, unity3d file is in valid, bundle path is {0} device is {1}", bundle_url, SystemInfo.deviceModel));
                yield break;
            }

            loadedAsset = bundle.LoadAsset("1", typeof(TextAsset));
            bundle.Unload(false);
#endif
            var textAsset = loadedAsset as TextAsset;
            mBytes = textAsset.bytes;
            Resources.UnloadAsset(textAsset);
        }
Esempio n. 4
0
        public override void Load()
        {
#if UNITY_EDITOR
            string resName = DBManager.AssetsResPath + "/" + mStrPath;

            TextAsset textObj = EditorResourceLoader.LoadAssetAtPath(resName, typeof(TextAsset)) as TextAsset;
            if (textObj != null)
            {
                string strData = CommonTool.BytesToUtf8(textObj.bytes);
                if (strData != "")
                {
                    ParseData(strData);
                }

                IsLoaded = true;
            }
            else
            {
                GameDebug.LogError("DB file load failed: " + mStrPath);
            }
#else
            AssetBundle db_bundle = DBManager.GetInstance().DBBundle;
            if (db_bundle != null)
            {
                string fileName = Path.GetFileNameWithoutExtension(mStrPath);
                Object resObj   = db_bundle.LoadAsset(fileName);

                TextAsset text = resObj as TextAsset;
                if (text != null)
                {
                    string strData = CommonTool.BytesToUtf8(text.bytes);
                    if (strData != "")
                    {
                        ParseData(strData);
                    }

                    IsLoaded = true;
                    Resources.UnloadAsset(text);
                }
                else
                {
                    GameDebug.LogError("DB file load failed: " + mStrPath);
                }
            }
            else
            {
                GameDebug.LogError("DB asset is null!!!");
            }
#endif

            /*AssetManager manager = Game.GetInstance().MainInterface.GetAssetManager();
             * if (manager== null)
             * {
             *      GameDebug.LogError("No AssetManager!");
             *      return;
             * }*/

            /*if (xc.Game.GetInstance().IsUsePackage() || Application.platform != RuntimePlatform.WindowsPlayer)
             * {
             *      string path = mStrPath;
             *      //string ext = Path.GetExtension(mStrPath).ToLower();
             *      manager.LoadAsset(path, LoadData);
             * }
             * else
             * {
             *      string path = "";
             *      string nameNoExtend = PathHelp.GetPathWithNoExtend(mStrPath);
             *
             *      path = "Resources/" + mStrPath;
             *      path = PathHelp.GetFullPaltformPath(path, false);
             *
             *      System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
             *      byte[] content = new byte[stream.Length];
             *      stream.Read(content, 0, (int)stream.Length);
             *
             *      IsLoaded = true;
             *
             *      string strData = AssetManager.BinToUtf8(content);
             *      ParseData(strData);
             *      stream.Close();
             * }*/
        }
Esempio n. 5
0
    /// <summary>
    /// 播放指定触发信息对应的特效
    /// </summary>
    public void PlayEffect(TriggerSetting effect_trigger)
    {
        if (!mIsEnable)
        {
            return;
        }

        if (effect_trigger.OnlyLocalPlayer && !mIsLocalPlayer)
        {
            return;
        }

#if UNITY_EDITOR
        if (InSkillEffectEditor())
        {
            GameObject effect_object = EditorResourceLoader.LoadAssetAtPath("Assets/Res/" + effect_trigger.SuitEffectPath(UseHighEffect? 0:1) + ".prefab", typeof(GameObject)) as GameObject;
            if (effect_object == null)
            {
                return;
            }

            effect_object = GameObject.Instantiate(effect_object) as GameObject;

            // 如果组件已经被销毁了,需要将gameobject放入内存池
            if (mIsDestory)
            {
                GameObject.Destroy(effect_object);
                return;
            }

            Transform effect_trans = effect_object.transform;
            Transform bind_trans   = effect_trigger.BindBone.transform;
            if (bind_trans == null)
            {
                bind_trans = mTrans;
            }

            if (bind_trans != null)
            {
                effect_trans.parent        = bind_trans;
                effect_trans.localPosition = Vector3.zero;
                effect_trans.localRotation = Quaternion.identity;
                effect_trans.localScale    = Vector3.one;

                if (effect_trigger.InWorld)// 特效不跟随角色
                {
                    effect_trans.parent = null;
                }
            }
            else
            {
                GameDebug.LogError("[LoadSkillEffect]bind_trans is null");
                GameObject.Destroy(effect_object);
                return;
            }

            var delay_timer = effect_object.GetComponent <DelayTimeComponent>();
            if (delay_timer == null)
            {
                delay_timer = effect_object.AddComponent <DelayTimeComponent>();
            }
            delay_timer.DelayTime = effect_trigger.LifeTime;
            delay_timer.Start();

            uint skillSoundId = 0;
            // 播放特效中的声音
            if (effect_trigger.Audio != null)
            {
                skillSoundId = AudioManager.Instance.PlayBattleSFX(effect_trigger.Audio, AudioManager.GetSFXSoundType(Owner));
                //AudioManager.Instance.PlayAudio(effect_trigger.Audio, false);
            }

            EffectInfo effect_info = new EffectInfo(effect_trigger, effect_object, skillSoundId);
            mEffectObjects[effect_object.GetHashCode()] = effect_info;
            delay_timer.SetEndCallBack(new DelayTimeComponent.EndCallBackInfo(OnEffectPlayFinish, effect_object));

            var shakes = effect_object.GetComponentsInChildren <CameraCurveShake>(true);
            foreach (var item in shakes)
            {
                item.enabled = true;
                item.StartShake();
            }
        }
        else
#endif
        StartCoroutine(LoadSkillEffect(effect_trigger));
    }