![]() ![]() ![]() If you need to change this, ensure that you also change the type of MonoBehaviour firstList. I assume that we will always be looking for types that inherit from MonoBehaviour, but this will usually be the case, with custom types. We have event system and many other other important systems based on SOs. But new people who will come here may find to difficult to locate a specific SO, or its Type. MonoBehaviour firstList = GameObject.FindObjectsOfType() We have all Scriptable Objects (SOs) in the ScriptableObjects folder (arranged folderwise also inside). Public List FindObjectsOfTypeAndName(string name) where T : MonoBehaviour It might be more useful to have a standalone method that can perform the required search, and take in custom types and names. We could also use List finalList, and find the actual gameObject reference with finalList.Add(basicAIList.gameObject, if we wanted a list of game objects.Ĭonsider that you may want to search like this multiple times. String nameToLookFor = "name of game object" įor(var i = 0 i finalList to List with no problems. TypeToLookFor firstList = GameObject.FindObjectsOfType() To complete the search, simply search for objects based off type, and search through the resulting list for objects that match the name. One can be easily used on the fly, the other is provided as a standalone method, and can be used more dynamically. You also want to consider whether searching for game objects by tag would be more appropriate for your requirements.īelow, I have provided two methods for searching for game objects by type and name. You can easily search for all active game objects based off type, and search the resulting list for all game objects of type that use name. ![]() Ultimately, you can not search for all active game objects based off both type and name, at the same time. There are different ways you would go about this depending on your particular circumstances. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |