Example #1
0
        //Instantiate the ObjectRecyler that will control my OneShotAudioSources
        private void InstantiateRecycler()
        {
            GameObject go = new GameObject();

            go.AddComponent <AudioSource>();
            go.name = "OneShotAudioSource";

            this.oneshotAudioRecycler = new ObjectRecycler(go, 2);

            Destroy(go);
        }
Example #2
0
        //Gets a Recycler. If there isn't one, make it!
        private ObjectRecycler GetRecycler(int recyclerID, GameObject goToMake)
        {
            if (this.recyclerDictionary.ContainsKey(recyclerID))
            {
                return(this.recyclerDictionary[recyclerID]);
            }
            else
            {
                ObjectRecycler newOR = new ObjectRecycler(goToMake, 0);

                this.recyclerDictionary.Add(recyclerID, newOR);

                return(newOR);
            }
        }
Example #3
0
        private GameObject GetNextFreeObject(GameObject goToGet)
        {
            if (!IsRecycleable(goToGet))   //Make sure it has an ID
            {
                this.MakeRecycleable(goToGet);
            }

            int id = this.GetRecyclerID(goToGet);              //Get the ID so we can get the corresponding Recycler

            ObjectRecycler oR = this.GetRecycler(id, goToGet); //Get the Recycler, send GO incase we need to make a new one

            GameObject tempGO = oR.nextFreeObject;

            this.AttachRO(tempGO, id);

            return(tempGO);   //Return nextFree!
        }
Example #4
0
        //Gets a Recycler. If there isn't one, make it!
        private ObjectRecycler GetRecycler(int recyclerID, GameObject goToMake)
        {
            if(this.recyclerDictionary.ContainsKey(recyclerID))
            return this.recyclerDictionary[recyclerID];
            else
            {
            ObjectRecycler newOR = new ObjectRecycler(goToMake,0);

            this.recyclerDictionary.Add(recyclerID, newOR);

            return newOR;
            }
        }
        //Instantiate the ObjectRecyler that will control my OneShotAudioSources
        private void InstantiateRecycler()
        {
            GameObject go = new GameObject();
            go.AddComponent<AudioSource>();
            go.name = "OneShotAudioSource";

            this.oneshotAudioRecycler = new ObjectRecycler(go, 2);

            Destroy(go);
        }