Current code in NodeControllerRevCsharp.cs:
Resultant error message:
C# newbie having a little trouble accessing my Main Camera in code - I've got this working in JS, so I assume the solution to this is just extraordinary ignorance. I've looked up the error on UnityAnswers ( http://answers.unity3d.com/search.html?redirect=search%2Fsearch&q=CS0176 ) and either the existing answers are unhelpful or I just don't understand 'em.
Previous attempts to solve the issue can be found near the end of the code, commented out. All yielded a further rats nest of errors.
Would anybody care to hazard a solution? And perhaps a bug-finding methodology so I'm not constantly bothering the good people of Unity Answers? =)
Thanks for reading,
asked Apr 04 '12 at 11:52 AM
I've had a look at Rev's code and after some experimentation ...
You need to get component by the name of the class so it needs to be in quotes "className" It's also possible to call GetComponent by type
I'm quite new to c# but I know it's a stickler for type. So we ended up GetComponent-ing as className and also making sure that the variable was the same type.
There was also a problem that
CameraNode was defined in 2 different places, once in NodeController as a public class and once in CameraController as a sub-class ( member variable ?)
We eliminated the class in NodeController and changed
so that we are using the definition of the class from CameraController
GameObject.Find will find an active game object with the specified name.
gameObject and GameObject are two different things. gameObject refers to the game object the script is attached to and GameObject refers to the class and class methods associated with GameObject. GameObject.Find is a class method, not a member method.