#how do you use Type.GetType
1 messages · Page 1 of 1 (latest)
I dont think I am supposed to use unityEngine but I dont know what else to use?
how do you use Type.GetType
Are you trying to add your MyScript MonoBehaviour to test there?
oh hello again
Why are you using Type.GetType
My actual code has a list of strings that I will use to add monobehaviors
why
I want to dynamicly change what monobehavior is added to the object
It would end up looking more like this
What are you trying to achieve by doing this
If you ever find yourself using reflection you should probably have a damn good reason
what is reflection?
What you are attempting to do
Loading types at runtime
It's very slow, incredibly error prone and incredibly complicated and your IDE can do nothing to help
I want to add a spacific monobehavior based on what I input into a function
Stop trying to say what your attempted solution is and tell me what you are trying to do
I dont understand
You have yet to explain why you are trying to do this
I count find another way to do it
what’s the point of this from the players perspective
I create a new object and add a script to it so that object does what I want it to
I feel like I dont understantd the question
Why are you trying to add a type by name to an object
What is the point of doing this instead of just not doing it
What are you trying to achieve by doing this
There is a way to just do it?
@tidal birch are you trying to add a feature that lets the player add a random component from a list?
something along those lines?
not random but yes
a dictionary of <string, Type> could work. A list of Type might also work
how do you make a list of type
so it’s fine accessing it by index right?
or would you prefer accessing it by string
I think? I dont exactly know what that means sorry
nvm I would like to do it by string
create a dictionary
Dictionary<string, System.Type>
k
brb
do you know how to use a dictionary?
I found it, someone did the same thing before #archived-code-general message
k thanks