改变孩子是出界的(C#UNITY)

时间:2018-01-03 06:28:36

标签: c# android unity3d

在我的层次结构中,这是我的arrangement of gameobjects

这是我获取MediaPlayer gameObject的代码。

[SerializeField]
GameObject ump; // lets access the ump gameobject

 void Update()
{
    if (tzPlayInfo.Instance.MAKING_GAME_OBJECT == false)
    {
        //find the gameobject through getting the child of every component/gameobject
        ump = this.gameObject.transform.GetChild(0).GetChild(1).GetChild(1).GetChild(1).GetChild(0).GetChild(1).gameObject;
        if (ump != null) { 
        //Uses an If directives for the platform dependencies
        #if UNITY_ANDROID
            ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform = 2;
            if (ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform == 2)
            {
                Debug.Log("UMP property is set to Android");
                this.enabled = false;
            } else
            {
                Debug.Log("Couldn't set the property to Android");
            }
        #elif UNITY_STANDALONE
            ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform = 0;
            if(ump.GetComponent<UniversalMediaPlayer>()._chosenPlatform == 0){
                Debug.Log("UMP property is set to StandAlone/Windows");
                this.enabled = false;
            } else {
                Debug.Log("Couldn't set the property to StandAlone/Windows");
            }
        #else
        #endif
        } else
        {
            Debug.Log("Could not get the gameobject UMP");
        }

现在它总是给我一个错误,虽然我得到了我想要的东西。

0 个答案:

没有答案