15588人加入学习
(100人评价)
通过实例学习:游戏的存档与读档(Unity 2017.2)

制作完成于2018-1-12

价格 免费
  • 游戏物体激活:

游戏物体.SetActive(true);

  • 游戏物体组件激活:

游戏物体.GetComponent<组件>().enabled=true;

[展开全文]

1.通过关键字存储PlayerPrefs.SetInt( )

直接存储int等数据类型的数据

获取数值PlayerPrefs.GetInt( )

[展开全文]

gameObject.GetComponentInParent<脚本>().UpdateMonsters();

通过父物体调用脚本

[展开全文]

//随机生成怪物,用索引生成

public GameObject[] monstrers;
    public GameObject activeMonster = null;
    void Start()
    {
        foreach ( GameObject   monstrer in monstrers)
        {
            monstrer.SetActive(false);
            monstrer.GetComponent<BoxCollider>().enabled = false;
           
       
        }
        ActivateMonster();
    }
    private void ActivateMonster()
    {
        int index = Random.Range(0, monstrers.Length);
        activeMonster = monstrers[index];
        activeMonster.SetActive(true);
        activeMonster.GetComponent<BoxCollider>().enabled = true;
    }
  
    // Update is called once per frame
[展开全文]

//协程控制随机时间内生成怪物

IEnumerator AliveTimer()
    {
        yield return new WaitForSeconds(Random.Range(1, 5));
        ActivateMonster();
    }

[展开全文]

[system.serializable]

可序列化

[展开全文]

anim = GetComponent<Animation>();  //这里犯错误了:写成了anim.GetComponent<Animation>()

对需要拖拽赋值的物体的感想

[展开全文]

http://blog.csdn.net/y1196645376/article/details/52541882

[展开全文]

授课教师

SIKI学院老师

课程特色

图文(1)
下载资料(1)
视频(34)