#how do you use Type.GetType

1 messages · Page 1 of 1 (latest)

tidal birch
#

I dont think I am supposed to use unityEngine but I dont know what else to use?

#

how do you use Type.GetType

outer mica
#

Are you trying to add your MyScript MonoBehaviour to test there?

tidal birch
#

oh hello again

sly pollen
tidal birch
#

My actual code has a list of strings that I will use to add monobehaviors

tidal birch
#

I want to dynamicly change what monobehavior is added to the object

#

It would end up looking more like this

sly pollen
#

What are you trying to achieve by doing this

#

If you ever find yourself using reflection you should probably have a damn good reason

tidal birch
#

what is reflection?

sly pollen
#

Loading types at runtime

#

It's very slow, incredibly error prone and incredibly complicated and your IDE can do nothing to help

tidal birch
#

I want to add a spacific monobehavior based on what I input into a function

sly pollen
#

Stop trying to say what your attempted solution is and tell me what you are trying to do

tidal birch
#

I dont understand

sly pollen
#

You have yet to explain why you are trying to do this

tidal birch
#

I count find another way to do it

round sentinel
tidal birch
#

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

sly pollen
#

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

tidal birch
#

There is a way to just do it?

round sentinel
#

@tidal birch are you trying to add a feature that lets the player add a random component from a list?

#

something along those lines?

tidal birch
#

not random but yes

round sentinel
#

a dictionary of <string, Type> could work. A list of Type might also work

tidal birch
#

how do you make a list of type

round sentinel
#

or would you prefer accessing it by string

tidal birch
#

I think? I dont exactly know what that means sorry

#

nvm I would like to do it by string

round sentinel
tidal birch
#

k

round sentinel
#

brb

round sentinel
tidal birch
#

no but I am looking it up

#

I think I get it

#

It is exacly what I need thanks

round sentinel
tidal birch
#

k thanks