Unity3D中预制体Prefab的应用
来源:互联网 发布:淘宝封号花呗怎么处理 编辑:程序博客网 时间:2024/06/07 07:31
预制体Prefab;相对于一个GameObject模板,方便多次使用。
预制体,如何通过脚本动态加载呢:
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LoadPrefab : MonoBehaviour { public GameObject bullet;// Use this for initializationvoid Start () { Instantiate(bullet);}// Update is called once per framevoid Update () {}}
1. 挂载到某个GameObject下面:
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LoadPrefab : MonoBehaviour { public GameObject goBullet; private GameObject bullet;// Use this for initializationvoid Start () { bullet = Instantiate(goBullet); bullet.transform.parent = this.transform;}// Update is called once per framevoid Update () {}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LoadPrefab : MonoBehaviour { public GameObject goBullet; private GameObject bullet;// Use this for initializationvoid Start () { bullet = Resources.Load("Bullet") as GameObject; bullet.transform.parent = this.transform;}// Update is called once per framevoid Update () {}}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class CreateObject : MonoBehaviour { GameObject gun;// Use this for initializationvoid Start () { gun = new GameObject("gun"); gun.AddComponent<LoadPrefab>();}// Update is called once per framevoid Update () {}}
1 0
- Unity3D中预制体Prefab的应用
- UNITY3D自学(四)--创建预制体Prefab--第一集
- Unity3D中Prefab的使用
- UNITY3D自学(四)--创建预制体Prefab--第2集
- Unity3D加载预制体到场景中
- Unity3d中加载资源prefab的方法
- Unity3D中Prefab
- Unity3D中Prefab
- unity3d 预制体
- Unity3d保存选中预制体
- Unity3D之Prefab的制作
- Unity3d学习 预设体(prefab)的一些理解
- Unity3D研究院之Prefab里面的Prefab关联问题
- 预制件(prefab)资源的应用
- unity3d添加子弹爆炸预制体动画
- unity3d预制体修改与保存
- Unity3D预制体光照贴图加载
- [cnblogs镜像]Unity 指定区域随机实例化预制体Prefab 代码
- 自适应辛普森(近似求积分)
- Ubuntu16.04 搜狗输入法无法显示中文
- HttpServletRequest和HttpServletResponse详解
- grails学习总结
- Javascript闭包用法实例分析
- Unity3D中预制体Prefab的应用
- 下拉加载
- Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)
- 2017全球机器学习技术大会5月1日前报名享7折早鸟票优惠
- SQLite中使用CTE巧解多级分类的级联查
- SpringMVC的各种参数绑定方式
- 简述 什么是spring MVC
- HDU
- 当我在做技术管理时,我在做什么?