コード例 #1
0
        void IConsoleWindow.OnGUI()
        {
            // 如果游戏模块没有创建
            if (MotionEngine.Contains(typeof(GameObjectPoolManager)) == false)
            {
                _scrollPos = ConsoleGUI.BeginScrollView(_scrollPos, 30);
                ConsoleGUI.YellowLable($"{nameof(GameObjectPoolManager)} is not create.");
                ConsoleGUI.EndScrollView();
                return;
            }

            var pools = GameObjectPoolManager.Instance.GetAllCollectors;

            ConsoleGUI.Lable($"池总数:{pools.Count}");

            _scrollPos = ConsoleGUI.BeginScrollView(_scrollPos, 30);
            foreach (var pair in pools)
            {
                string content = $"[{pair.Value.Location}] CacheCount = {pair.Value.Count} SpwanCount = {pair.Value.SpawnCount}";
                if (pair.Value.States == EAssetStates.Fail)
                {
                    ConsoleGUI.RedLable(content);
                }
                else
                {
                    ConsoleGUI.Lable(content);
                }
            }
            ConsoleGUI.EndScrollView();
        }
コード例 #2
0
        void IModule.OnCreate(object createParam)
        {
            // 检测依赖模块
            if (MotionEngine.Contains(typeof(ResourceManager)) == false)
            {
                throw new Exception($"{nameof(GameObjectPoolManager)} depends on {nameof(ResourceManager)}");
            }

            CreateParameters parameters = createParam as CreateParameters;

            if (createParam == null)
            {
                throw new Exception($"{nameof(GameObjectPoolManager)} create param is invalid.");
            }
            if (parameters.DefaultMaxCapacity < parameters.DefaultInitCapacity)
            {
                throw new Exception("The max capacity value must be greater the init capacity value.");
            }

            _enableLazyPool      = parameters.EnableLazyPool;
            _defaultInitCapacity = parameters.DefaultInitCapacity;
            _defaultMaxCapacity  = parameters.DefaultMaxCapacity;
            _defaultDestroyTime  = parameters.DefaultDestroyTime;

            _root = new GameObject("[PoolManager]");
            _root.transform.position    = Vector3.zero;
            _root.transform.eulerAngles = Vector3.zero;
            UnityEngine.Object.DontDestroyOnLoad(_root);
        }
コード例 #3
0
 void IModule.OnCreate(System.Object param)
 {
     // 检测依赖模块
     if (MotionEngine.Contains(typeof(ResourceManager)) == false)
     {
         throw new Exception($"{nameof(ConfigManager)} depends on {nameof(ResourceManager)}");
     }
 }
コード例 #4
0
 void IModule.OnCreate(object createParam)
 {
     // 检测依赖模块
     if (MotionEngine.Contains(typeof(ResourceManager)) == false)
     {
         throw new Exception($"{nameof(WindowManager)} depends on {nameof(ResourceManager)}");
     }
 }
コード例 #5
0
        void IModule.OnCreate(System.Object param)
        {
            // 检测依赖模块
            if (MotionEngine.Contains(typeof(ResourceManager)) == false)
            {
                throw new Exception($"{nameof(AudioManager)} depends on {nameof(ResourceManager)}");
            }

            _root = new GameObject("[AudioManager]");
            UnityEngine.Object.DontDestroyOnLoad(_root);

            foreach (int value in System.Enum.GetValues(typeof(EAudioLayer)))
            {
                EAudioLayer layer = (EAudioLayer)value;
                _audioSourceWrappers.Add(layer, new AudioSourceWrapper(layer.ToString(), _root.transform));
            }
        }
コード例 #6
0
    private IEnumerator LoadAssets()
    {
        GameObject uiRoot = GameObject.Find("UIRoot");

        // 加载窗口
        GameLog.Log("Load Window");
        GameObject window;

        {
            var handle = ResourceManager.Instance.LoadAssetAsync <GameObject>("UIPanel/LoginWindow");
            yield return(handle);

            window = handle.InstantiateObject;             // 实例化对象
            window.transform.SetParent(uiRoot.transform, false);

            var versionTxt = window.transform.BFSearch("Version").GetComponent <Text>();
            if (MotionEngine.Contains(typeof(PatchManager)))
            {
                versionTxt.text = $"Version : {PatchManager.Instance.GetRequestedGameVersion()}";
            }
            else
            {
                versionTxt.text = "NO Server";
            }
        }

        // 加载背景图片
        GameLog.Log("Load Texture");
        {
            var handle1 = ResourceManager.Instance.LoadAssetAsync <Texture>("UITexture/Background/bg.png");
            yield return(handle1);

            var bg1 = window.transform.BFSearch("Bg1").GetComponent <RawImage>();
            bg1.texture = handle1.AssetObject as Texture;

            var handle2 = ResourceManager.Instance.LoadAssetAsync <Texture>("UITexture/Background/bg.jpg");
            yield return(handle2);

            var bg2 = window.transform.BFSearch("Bg2").GetComponent <RawImage>();
            bg2.texture = handle2.AssetObject as Texture;
        }

        // 加载精灵图片
        {
            GameLog.Log("Load Sprite");

            // 设置精灵1
            var handle1 = ResourceManager.Instance.LoadAssetAsync <Sprite>("UITexture/Foods/eggs");
            yield return(handle1);

            Image img1 = window.transform.BFSearch("FoodImg1").GetComponent <Image>();
            img1.sprite = handle1.AssetObject as Sprite;
            img1.SetNativeSize();

            // 设置精灵2
            var handle2 = ResourceManager.Instance.LoadAssetAsync <Sprite>("UITexture/Foods/apple");
            yield return(handle2);

            Image img2 = window.transform.BFSearch("FoodImg2").GetComponent <Image>();
            img2.sprite = handle2.AssetObject as Sprite;
            img2.SetNativeSize();
        }

        // 加载模型
        {
            GameLog.Log("Load Monster");
            var handle = ResourceManager.Instance.LoadAssetAsync <GameObject>("Entity/Monster/Boss");
            yield return(handle);

            var sphere = handle.InstantiateObject;             // 实例化对象
            sphere.transform.position   = new Vector3(5f, 0, 0);
            sphere.transform.localScale = sphere.transform.localScale * 2f;
        }

        // 加载LUA文件
        GameLog.Log("Load LUA");
        {
            var       handle1 = ResourceManager.Instance.LoadAssetSync <TextAsset>("Lua/LuaTest1.lua");
            TextAsset lua1    = handle1.AssetObject as TextAsset;
            Debug.Log(lua1.text);

            var       handle2 = ResourceManager.Instance.LoadAssetSync <TextAsset>("Lua/LuaTest2.lua.txt");
            TextAsset lua2    = handle2.AssetObject as TextAsset;
            Debug.Log(lua2.text);
        }
    }
コード例 #7
0
    private IEnumerator LoadAssets()
    {
        // 加载UI面板
        GameLog.Log("Load UIRoot.");
        var rootHandle = ResourceManager.Instance.LoadAssetAsync <GameObject>("UIPanel/UIRoot");

        yield return(rootHandle);

        GameObject uiRoot = rootHandle.InstantiateObject;         // 实例化对象

        // 加载窗口
        GameLog.Log("Load LoginWindow");
        GameObject window;
        {
            var handle = ResourceManager.Instance.LoadAssetAsync <GameObject>("UIPanel/LoginWindow");
            yield return(handle);

            window = handle.InstantiateObject;             // 实例化对象
            window.transform.SetParent(uiRoot.transform, false);

            var versionTxt = window.transform.BFSearch("Version").GetComponent <Text>();
            if (MotionEngine.Contains(typeof(PatchManager)))
            {
                versionTxt.text = PatchManager.Instance.GetRequestedGameVersion().ToString();
            }
            else
            {
                versionTxt.text = "NO Server";
            }
        }

        // 加载资源包
        {
            GameLog.Log("Load texture package");
            _handle1 = ResourceManager.Instance.LoadAssetAsync <Texture>("UITexture/Foods/eggs");
            yield return(_handle1);

            Texture tex1 = _handle1.AssetObject as Texture;

            _handle2 = ResourceManager.Instance.LoadAssetAsync <Texture>("UITexture/Foods/apple");
            yield return(_handle2);

            Texture tex2 = _handle2.AssetObject as Texture;

            // 设置纹理1
            RawImage img1 = window.transform.BFSearch("FoodImg1").GetComponent <RawImage>();
            img1.texture = tex1;
            img1.SetNativeSize();

            // 设置纹理2
            RawImage img2 = window.transform.BFSearch("FoodImg2").GetComponent <RawImage>();
            img2.texture = tex2;
            img2.SetNativeSize();
        }

        // 加载模型
        {
            GameLog.Log("Load Monster");
            var handle = ResourceManager.Instance.LoadAssetAsync <GameObject>("Entity/Monster/Boss");
            yield return(handle);

            var sphere = handle.InstantiateObject;             // 实例化对象
            sphere.transform.position   = new Vector3(5f, 0, 0);
            sphere.transform.localScale = sphere.transform.localScale * 2f;
        }
    }