首页 > 其他分享 >unity3d修改对象属性

unity3d修改对象属性

时间:2022-11-11 21:55:22浏览次数:47  
标签:unity3d obj string BDID transform 修改 GetComponent 属性

unity3d修改对象属性

 

    #region
    void loadWorkerModel(Vector3 init_position, string worker_name,string BDID)
    {
        GameObject obj = (GameObject)Instantiate(Resources.Load("Prefabs/Worker_commomn"));

        obj.transform.position = init_position;
        
        obj.AddComponent<CapsuleCollider>();//添加碰撞
        obj.GetComponent<CapsuleCollider>().radius = 1;
        obj.GetComponent<CapsuleCollider>().height = 1;
        obj.name = worker_name;


        obj.AddComponent<WorkerPositionController>();//加载脚本
        obj.transform.parent = this.transform;
        string str_BDID = BDID.Remove(0, BDID.Length - 2);
        obj.GetComponent<WorkerPositionController>().setWorkerIDText(str_BDID);


    }
    #endregion

 

 

 

 

 

################

标签:unity3d,obj,string,BDID,transform,修改,GetComponent,属性
From: https://www.cnblogs.com/herd/p/16882143.html

相关文章