Hi guys
I have this in js, which exposes a slot in the editor to allow me to place a texture array on it.
var textures : TextureArray = selected.GetComponent(TextureArray);
How would I do the same in C#?
Completely stuck
Thanks
Hi guys
I have this in js, which exposes a slot in the editor to allow me to place a texture array on it.
var textures : TextureArray = selected.GetComponent(TextureArray);
How would I do the same in C#?
Completely stuck
Thanks
If “TextureArray” is defined correctly and “selected” is a GameObject:
TextureArray textures = selected.GetComponent<TextureArray>();
Actually, you need to declare the variable as public since I believe the default protection level in C# is “protected,” whereas in JS it’s “public.” So, slight modification:
public TextureArray textures = selected.GetComponent<TextureArray> ();
FYI, default access level in C# is private, not protected. But you are correct, you would want to explicitly mark the member as public.
Thanks guys
I have actually decided to add the array to the same script thus bypassing the need to access it from another. But this is a great help, I’m sure I will need it for something else later.
Cheers