Unity 使用自定义资源(.asset) 添加 Assets 菜单按钮二
2017-12-18 11:36
267 查看
Unity 使用自定义资源(.asset) 添加 Assets 菜单按钮二
之前一篇Unity使用自定义资源(.asset)上篇依然有效,添加一个创建 .asset 的方法,在 Assets 菜单栏添加一个创建按钮,执行创建。
Bullet.cs 代码如下
类上面添加一行
[CreateAssetMenu(fileName = "Bullet", menuName = "New Bullet", order = 1)]
作用在 Assets 文件夹下,鼠标右键,菜单栏中添加一个按钮项,菜单名为 menuName,并执行生成名为 fileName 的脚本,order 为按钮显示顺序
using System.Collections; using System.Collections.Generic; using UnityEngine; // 在 Assets 下添加菜单 // fileName 生成名为 Bullet的脚本 // menuName 菜单按钮名New Bullet // order 按钮显示顺序 [CreateAssetMenu(fileName = "Bullet", menuName = "New Bullet", order = 1)] public class Bullet: ScriptableObject { // Bullet 类直接继承自 ScriptableObject // 子弹速度 public int speed = 10; // 伤害数值 public int damage = 5; // 子弹关联的特效 public GameObject effectObj; public bool CompareSpeed(float _speed) { return speed > _speed; } }
在 Assets 下任意文件夹内,鼠标右键, Create -> New Bullet
在鼠标所在目录下,生成 Bullet.asset
相关文章推荐
- Unity使用自定义资源(.asset)配置数据
- Unity 使用自定义资源(.asset)配置数据
- unity 菜单按钮添加及相应窗口的实现
- Unity 使用自定义资源(.asset)配置数据
- 【Unity快速实现小功能】NGUI篇——快速使用UIEventListener组件实现,按钮点击功能并添加相应的处理函数
- Unity 使用自定义资源(.asset)配置数据
- 美化你的标题栏—ActionBar(1)添加按钮使用
- Android4.3模拟器界面中右侧菜单按钮无法使用问题解决办法
- Unity游戏开发使用Assetbundle加载场景的原理
- ActionBar简单使用——添加搜索按钮;让不同的Activity上显示不同的ActionBar;添加Tab标签;实现DrawerLayout并用ActionBarDrawerToggle控制
- iOS 9应用开发教程之使用代码添加按钮美化按钮
- Unity游戏开发使用Assetbundle加载场景实战
- 在Unity菜单栏上添加自定义菜单
- CursorLoader获取联系人并使用选项菜单添加联系人
- Android 6.0开发实现关机菜单添加重启按钮的方法
- MFC中为菜单或按钮添加快捷键功能
- unity-----------------------使用BuildAssetBundle打包
- ListView中使用单例添加按钮事件监听
- 使用Android studio添加assets目录
- cocos2d-x-3.0学习笔记之如何添加菜单按钮