zoukankan      html  css  js  c++  java
  • GameObject

    查找

    GameObject-find
    //must sure the thing or things in the hierachy then you can find
    GameObject obj = GameObject.Find("");//查找名字为“”的物体
    GameObject obj = GameObject.FindGameObjectWithTag("");//查找一个物体标签为“”
    GameObject[] objs = GameObject.FindGameObjectsWithTag("");//查找所有物体标签为“”的,且放置到数组中
    for (int i = 0; i < objs.Length; i++)
    {
    Debug.Log(objs[i].name);

    }

    克隆

    GameOject-clone
    public GameObject cubeobj;//克隆母本
    GameObject obj = GameObject.Instantiate(cubeobj, cubeobj.transform.position, cubeobj.transform.rotation) as GameObject;//原地克隆Start函数里
    GameObject obj = GameObject.Instantiate(cubeobj, new Vector3(1, 2, 3), cubeobj.transform.rotation) as GameObject;

    Instantiate (prefab, Vector3(2.0, 0, 0), Quaternion.identity);
    prefab是被克隆的对象, 第二个变量是克隆体生成的位置,第三个变
    量表示该生成的克隆不旋转。
    对第三个变量详解:
    Quaternion 四元数,用来表示旋转

    销毁

    GameObject- Destroy
    public float time = 1;
    Destroy(gameObject, time);//gameObject为挂脚本的物体

    Prefab-将Hierarchy里的物体拖拽到Assets面板即可
    -导入素材

  • 相关阅读:
    高精度计算模板
    P1108 低价购买 [DP][统计方案]
    POJ3349 Snowflake Snow Snowflakes [哈希]
    P1312 Mayan游戏 [深搜][模拟]
    P1378 油滴扩展[深搜]
    P1514 引水入城[搜索,线段覆盖]
    TYVJ1391 走廊泼水节
    【BZOJ1196】公路修建问题
    【BZOJ3624】免费道路
    【BZOJ2429】聪明的猴子
  • 原文地址:https://www.cnblogs.com/ShineaSYR/p/5417153.html
Copyright © 2011-2022 走看看