コード例 #1
0
ファイル: TestPool.cs プロジェクト: 542767059/ABC
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.B))
        {
            GameEntry.Resource.LoadAsset("102000", typeof(GameObject), 0,
                                         new LoadAssetCallbacks((assetName, asset, duration, userData) =>
            {
                Debug.Log(assetName);
                GameObject obj = (GameObject)asset;
                GameObjectPool = new GameObjectPool(obj);
                Debug.Log(duration);
                Debug.Log(userData);
            }), 1);
        }

        if (Input.GetKeyUp(KeyCode.A))
        {
            GameObjectPool = new GameObjectPool(sds);
        }
        if (Input.GetKeyUp(KeyCode.C))
        {
            GameObject obj = GameObjectPool.Spawn();

            StartCoroutine(Despawn(obj));
        }

        if (Input.GetKeyUp(KeyCode.D))
        {
            GameObjectPool.Clear();
        }
    }
コード例 #2
0
    public void Destroy()
    {
        foreach (var d in dependenceds.ToArray())
        {
            d.Remove(this);
        }

        arrows.Clear();
        FindObjectOfType <CampaignEditorBehaviourView>().RemoveStage(this);

        Destroy(gameObject);
    }
コード例 #3
0
        private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            animationPool.Clear();

            var poolObject = new GameObject();

            poolObject.name = "PooledObjects";
            poolObject.SetActive(false);

            parent = poolObject.transform;

            GlobalState.EventService.Persistent.AddEventHandler <AnimationCompleteEvent>(OnAnimationComplete);
        }
コード例 #4
0
 public static IEnumerator Unload()
 {
     if (isReady)
     {
         isReady = false;
         if (s_spellEffectCache != null)
         {
             UnloadCache(s_spellEffectCache);
             s_spellEffectCache = null;
         }
         if (s_propertyEffectCache != null)
         {
             UnloadCache(s_propertyEffectCache);
             s_propertyEffectCache = null;
         }
         if (s_sightEffectCache != null)
         {
             UnloadCache(s_sightEffectCache);
             s_sightEffectCache = null;
         }
         if (s_floatingCounterEffectCache != null)
         {
             UnloadCache(s_floatingCounterEffectCache);
             s_floatingCounterEffectCache = null;
         }
         if (s_floatingCounterFeedbackPool != null)
         {
             s_floatingCounterFeedbackPool.Clear();
             s_floatingCounterFeedbackPool = null;
         }
         if (s_loadedSpellDefinitions != null)
         {
             foreach (SpellDefinition s_loadedSpellDefinition in s_loadedSpellDefinitions)
             {
                 if (null != s_loadedSpellDefinition)
                 {
                     s_loadedSpellDefinition.UnloadResources();
                 }
             }
             s_loadedSpellDefinitions.Clear();
             s_loadedSpellDefinitions = null;
         }
         s_currentSpellEffectOverrideData = null;
         s_instance = null;
         AssetBundleUnloadRequest unloadRequest = AssetManager.UnloadAssetBundle("core/factories/fight_object_factory");
         while (!unloadRequest.get_isDone())
         {
             yield return(null);
         }
     }
 }
コード例 #5
0
        public void TearDown()
        {
            foreach (GameObject go in testObjects)
            {
                GameObject.Destroy(go);
            }
            testObjects = null;

            GameObject.Destroy(testPrefab);
            testPrefab = null;

            testPool.Clear();
            testPool = null;
        }
コード例 #6
0
        public IEnumerator Initialize()
        {
            TestRunnerHelper.testBoolean = false;

            InitailizeObjectPool();

            Action onInitialize = () => { TestRunnerHelper.testBoolean = true; };

            objectPool.OnInitailize = onInitialize;
            objectPool.Initialize(config.initialize_prefab, config.initialize_count);

            Assert.AreEqual(TestRunnerHelper.testBoolean, true);
            Assert.AreEqual(config.initialize_count, objectPool.Count);

            objectPool.Clear();
            Assert.AreEqual(0, objectPool.Count);

            yield return(null);
        }
コード例 #7
0
ファイル: GameManager.cs プロジェクト: GeordieP/DSAS
    public void ExitToMenu()
    {
        StopAllCoroutines();        // this could cause issues
        enemyPool.Clear();
        enemyBulletPool.Clear();
        playerBulletPool.Clear();
        bossBulletPool.Clear();

        player = null;
        Resources.UnloadUnusedAssets();

        // this may cause problems if we use timers for anything between calling this function
        // and transitioning the scene
        TimerManager.Instance.StopAndDeleteAll();

        // Transition scene to menu (should always be game scene index - 1)
        Time.timeScale = 1f;
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
コード例 #8
0
 private void OnGUI()
 {
     if (GUILayout.Button("创建"))
     {
         for (int i = 0; i < 2; i++)
         {
             Vector3 obj_pos = new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10));
             gop.CreateObject(Objnm[i], prefabObj[i], obj_pos, Quaternion.identity);
         }
     }
     if (GUILayout.Button("释放"))
     {
         gop.Clear("Cube");
     }
     if (GUILayout.Button("实时回收"))
     {
         gop.CollectObject(GameObject.FindGameObjectWithTag("Cube"));
     }
     if (GUILayout.Button("延时回收"))
     {
         gop.CollectObject(GameObject.FindGameObjectWithTag("Cube"), 5.0f);
     }
 }
コード例 #9
0
 public void Clear(bool includeUsingObject = true)
 {
     m_pool.Clear(includeUsingObject);
 }
コード例 #10
0
 private void OnDestroy()
 {
     Pool.Clear();
 }
コード例 #11
0
 protected static void ClearPool()
 {
     GameObjectPool.Clear();
 }