示例#1
0
    void OnInitialize()
    {
        LuaManager.InitStart();
        LuaManager.DoFile("Logic/Game");         //加载游戏
        LuaManager.DoFile("Logic/Network");      //加载网络
        NetManager.OnInit();                     //初始化网络
        Util.CallMethod("Game", "OnInitOK");     //初始化完成

        initialize = true;

        //类对象池测试
        // var classObjPool = ObjPoolManager.CreatePool<TestObjectClass>(OnPoolGetElement, OnPoolPushElement);
        //方法1
        //objPool.Release(new TestObjectClass("abcd", 100, 200f));
        //var testObj1 = objPool.Get();

        //方法2
        //  ObjPoolManager.Release<TestObjectClass>(new TestObjectClass("abcd", 100, 200f));
        // var testObj1 = ObjPoolManager.Get<TestObjectClass>();

        //游戏对象池测试
        var prefab      = Resources.Load("TestGameObjectPrefab", typeof(GameObject)) as GameObject;
        var gameObjPool = ObjPoolManager.CreatePool("TestGameObject", 5, 10, prefab);

        var gameObj = Instantiate(prefab) as GameObject;

        gameObj.name = "TestGameObject_01";
        gameObj.transform.localScale    = Vector3.one;
        gameObj.transform.localPosition = Vector3.zero;
        ObjPoolManager.Release("TestGameObject", gameObj);
        var backObj = ObjPoolManager.Get("TestGameObject");

        backObj.transform.SetParent(null);
        Debug.Log("TestGameObject--->>>" + backObj);
    }
示例#2
0
        void TestObject()
        {
            //类对象池测试
            var classObjPool = ObjPoolManager.CreatePool <TestObjectClass>(OnPoolGetElement, OnPoolPushElement);

            //方法1
            //objPool.Release(new TestObjectClass("abcd", 100, 200f));
            //var testObj1 = objPool.Get();

            //方法2
            ObjPoolManager.Release <TestObjectClass>(new TestObjectClass("abcd", 100, 200f));
            var testObj1 = ObjPoolManager.Get <TestObjectClass>();

            Debugger.Log("TestObjectClass--->>>" + testObj1.ToString());

            //游戏对象池测试
            var prefab      = Resources.Load("TestGameObjectPrefab", typeof(GameObject)) as GameObject;
            var gameObjPool = ObjPoolManager.CreatePool("TestGameObject", 5, 10, prefab);

            var gameObj = Instantiate(prefab) as GameObject;

            gameObj.name = "TestGameObject_01";
            gameObj.transform.localScale    = Vector3.one;
            gameObj.transform.localPosition = Vector3.zero;

            ObjPoolManager.Release("TestGameObject", gameObj);
            var backObj = ObjPoolManager.Get("TestGameObject");

            backObj.transform.SetParent(null);

            Debug.Log("TestGameObject--->>>" + backObj);
        }
示例#3
0
        /// <summary>
        /// 资源初始化结束
        /// </summary>
        public void OnResourceInited()
        {
            LuaManager.InitStart();
            LuaManager.DoFile("Logic/Game");            //加载游戏
            LuaManager.DoFile("Logic/Network");         //加载网络
            NetManager.OnInit();                        //初始化网络

            Util.CallMethod("Game", "OnInitOK");        //初始化完成
            initialize = true;                          //初始化完

            //类对象池测试
            var classObjPool = ObjPoolManager.CreatePool <TestObjectClass>(OnPoolGetElement, OnPoolPushElement);

            //方法1
            //objPool.Release(new TestObjectClass("abcd", 100, 200f));
            //var testObj1 = objPool.Get();

            //方法2
            ObjPoolManager.Release <TestObjectClass>(new TestObjectClass("abcd", 100, 200f));
            var testObj1 = ObjPoolManager.Get <TestObjectClass>();

            Debugger.Log("TestObjectClass--->>>" + testObj1.ToString());

            //游戏对象池测试
            var prefab      = Resources.Load("TestGameObjectPrefab", typeof(GameObject)) as GameObject;
            var gameObjPool = ObjPoolManager.CreatePool("TestGameObject", 5, 10, prefab);

            var gameObj = Instantiate(prefab) as GameObject;

            gameObj.name = "TestGameObject_01";
            gameObj.transform.localScale    = Vector3.one;
            gameObj.transform.localPosition = Vector3.zero;

            ObjPoolManager.Release("TestGameObject", gameObj);
            var backObj = ObjPoolManager.Get("TestGameObject");

            backObj.transform.SetParent(null);

            Debug.Log("TestGameObject--->>>" + backObj);

            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite));
            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite1));
            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite2));
            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite3));
            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite4));
            PoolManager.Instance.Get("TestGameObjectPrefab", "TestGameObjectPrefab", new Action <UnityEngine.Object>(LoadComplite5));

            /* PoolManager.Instance.Get("TestGameObjectPrefab","TestGameObjectPrefab",(obj)=>{
             *  GameObject temp = obj as GameObject;
             *
             * }); */
        }
示例#4
0
        void OnInitialize()
        {
            LuaManager.InitStart();
            LuaManager.DoFile("Logic/Game");         //加载游戏
            LuaManager.DoFile("Logic/Network");      //加载网络
            NetManager.OnInit();                     //初始化网络
            Util.CallMethod("Game", "OnInitOK");     //初始化完成

            initialize = true;

            //类对象池测试
            ObjPoolManager.CreatePool <TestObjectClass>(OnPoolGetElement, OnPoolPushElement);
            //方法1
            //objPool.Release(new TestObjectClass("abcd", 100, 200f));
            //var testObj1 = objPool.Get();

            //方法2
            ObjPoolManager.Release <TestObjectClass>(new TestObjectClass("abcd", 100, 200f));
            var testObj1 = ObjPoolManager.Get <TestObjectClass>();

            LogManager.Debug("TestObjectClass--->>>" + testObj1.ToString());

            //cube
            //ResManager.LoadPrefab("prefabs.unity3d", new string[] { "Cube" }, null);
            var prefab = LoadPrefab("prefabs.unity3d", "Cube") as GameObject;

            ObjPoolManager.CreatePool("Cube", 5, 10, prefab);
            //Particle
            //ResManager.LoadPrefab("prefabs.unity3d", new string[] { "Particle" }, null);
            prefab = LoadPrefab("prefabs.unity3d", "CircleParticle") as GameObject;
            ObjPoolManager.CreatePool("CircleParticle", 1, 1, prefab);
            //游戏对象池测试
            //var prefab = Resources.Load("TestGameObjectPrefab", typeof(GameObject)) as GameObject;


            //var gameObj = Instantiate(prefab) as GameObject;
            //gameObj.name = "TestGameObject_01";
            //gameObj.transform.localScale = Vector3.one;
            //gameObj.transform.localPosition = Vector3.zero;

            //ObjPoolManager.Release("TestGameObject", gameObj);
            //var backObj = ObjPoolManager.Get("TestGameObject");
            //if (backObj != null)
            //{
            //    backObj.transform.SetParent(null);
            //}

            //LogManager.Debug("TestGameObject--->>>" + backObj);
        }
        void OnInitialize()
        {
            LuaManager.InitStart();
            NetManager.OnInit();                     //初始化网络
            initialize = true;

            //类对象池测试
            var classObjPool = ObjPoolManager.CreatePool <TestObjectClass>(OnPoolGetElement, OnPoolPushElement);

            //方法1
            //objPool.Release(new TestObjectClass("abcd", 100, 200f));
            //var testObj1 = objPool.Get();

            //方法2
            ObjPoolManager.Release <TestObjectClass>(new TestObjectClass("abcd", 100, 200f));
            var testObj1 = ObjPoolManager.Get <TestObjectClass>();

            Log.Info("TestObjectClass--->>>" + testObj1.ToString());

            //游戏对象池测试
            var prefab      = Resources.Load("TestGameObjectPrefab", typeof(GameObject)) as GameObject;
            var gameObjPool = ObjPoolManager.CreatePool("TestGameObject", 5, 10, prefab);

            var gameObj = Instantiate(prefab) as GameObject;

            gameObj.name = "TestGameObject_01";
            gameObj.transform.localScale    = Vector3.one;
            gameObj.transform.localPosition = Vector3.zero;

            ObjPoolManager.Release("TestGameObject", gameObj);
            var backObj = ObjPoolManager.Get("TestGameObject");

            backObj.transform.SetParent(null);

            Log.Info("TestGameObject--->>>" + backObj);

            PanelManager.CreatePanel("Prompt", delegate(GameObject go)
            {
                Log.Info("Prompt created");
            });
        }