+ 1

Why is that when i try to assign a variable i always get an error saying that it is read-only?

Read-Only! Please explain.

3rd May 2017, 3:24 PM
DoubleVermine
DoubleVermine - avatar
4 odpowiedzi
+ 8
int i = 5; will not give an error. Can you give an example?
3rd May 2017, 3:39 PM
Rrestoring faith
Rrestoring faith - avatar
+ 8
Use get component to grab the collider as an object. mainPlayer.GetComponent(collider type); Though you're likely looking to add the component, so you can use: mainPlayer.AddComponent(playerCollider); This will add the playerCollider component to the GuiTexture.
3rd May 2017, 4:57 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
Thank you very much! It solved my problem.
3rd May 2017, 5:29 PM
DoubleVermine
DoubleVermine - avatar
+ 1
I'm not sure if you've ever worked with unity but if you do here is an example..... GuiTexture mainPlayer; Collider playerCollider; mainPlayer.collider = playerCollider; I cant assign the collider to it and it says it is read only. Please let me know!
3rd May 2017, 3:51 PM
DoubleVermine
DoubleVermine - avatar