What is the easiest way to getcomponent in Unity3D C#?
My case:
GameObject gamemaster.
A boolean backfacedisplayed(in MainGameLogic.cs).
A function BackfaceDisplay()(in MainGameLogic.cs).
Another C#script FlipMech.csthat I need to check from MainGameLogic.cs if(backfacedisplayed == TRUE)is what I will call BackfaceDisplay()from MainGameLogic.cs. How can I do this in C #?
In js, it's pretty straight forward. In FlipMech.js:
//declare gamemaster
var gamemaster:GameObject;
Then where I need to:
if(gamemaster.GetComponent(MainGameLogic).backfacedisplayed==true)
{
gamemaster.GetComponent(MainGameLogic).BackfaceDisplay();
}
But it seems to C#be more complex than that.
source
share