unity3d修改对象属性

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

 

 

 

 

 

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

posted @ 2022-11-11 21:48  西北逍遥  阅读(67)  评论(0编辑  收藏  举报