-1

I have trying to build a game in Unity3D and I am using Unity 5.1.1 pro version, I have imported Google VR sdk, and I am getting this error.

void Awake() {
#if !UNITY_5_2
         // im getting a error on this line 
        GetComponentInChildren<VideoControlsManager>(true).Player = player;
#else
    GetComponentInChildren<VideoControlsManager>().Player = player;
#endif
  }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Moin5262
  • 27
  • 1
  • 6

2 Answers2

0

According to the documentation's first line, there isn't a <generictype> acceptable. But the example uses the <generictype>. You might submit a ticket to see which is correct. Because of the error, I suspect the definition line is the correct way of writing it. So...

Write your line this way:

GetComponentInChildren(typeof(VideoControlsManager)).Player = player;
Chuck Savage
  • 11,775
  • 6
  • 49
  • 69
0

you can use Component.GetComponentsInChildren because it takes a boolean value to include the inactive objects, but because it returns an array you can use an ForEach to assign your variable to each element

 public VideoControlsManager[] VideoControlsManagers;
VideoControlsManagers = GetComponentsInChildren<VideoControlsManager>(true);

        foreach( VideoControlsManager v in VideoControlsManagers )
            v.Player  = player;
Milad Qasemi
  • 3,011
  • 3
  • 13
  • 17