unity Editor的使用
1.首先定义一个需要控制数值的类,类中定义若干个变量
using UnityEngine;
using System.Collections;
using UnityEngine;
using System.Collections; // This is not an editor script.
public class MyPlayer : MonoBehaviour {
public int Jump; void Update () {
// Update logic here...
}
}
2.创建Editor文件夹

3.创建Editor类,这里我取名为CatEditor

现附上代码下面说明
using UnityEditor;
using UnityEngine; [CustomEditor(typeof(RenControll))]
[CanEditMultipleObjects]
public class CatEditor : Editor
{ SerializedProperty _Jump; void OnEnable()
{
// Setup the SerializedProperties.
_Jump = serializedObject.FindProperty("Jump"); } public override void OnInspectorGUI()
{
// Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
serializedObject.Update(); EditorGUILayout.IntSlider(_Jump, 0, 100, new GUIContent("跳跃次数")); // Only show the armor progress bar if all the objects have the same armor value:
if (!_Jump.hasMultipleDifferentValues)
ProgressBar(_Jump.intValue / 100.0f, "Attack"); // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
serializedObject.ApplyModifiedProperties();
} // Custom GUILayout progress bar.
void ProgressBar(float value, string label)
{
// Get a rect for the progress bar using the same margins as a textfield:
Rect rect = GUILayoutUtility.GetRect(18, 18, "TextField");
EditorGUI.ProgressBar(rect, value, label);
EditorGUILayout.Space();
} }
[CustomEditor(typeof(RenControll))]找到我们游戏中用到的主体类.
_Jump = serializedObject.FindProperty("Jump"); 获取类中的jump变量
EditorGUILayout.IntSlider(_Jump, 0, 100, new GUIContent("跳跃次数"));
// Only show the armor progress bar if all the objects have the same armor value:
if (!_Jump.hasMultipleDifferentValues)
ProgressBar(_Jump.intValue / 100.0f, "Attack");
创建滑动条

打开unity就会显示可供调试的滑动条了.
unity Editor的使用的更多相关文章
- Spine用于Timeline(NullReferenceException: Object reference not set to an instance of an object pine.Unity.Editor.AnimationReferenceAssetEditor.OnInspectorGUI ())
报错信息:Spine.Unity.Editor.AnimationReferenceAssetEditor.OnInspectorGUI () (at Assets/Extention/Spine/E ...
- Unity Editor 下创建Lua和Text文件
预览 在Project视图中,扩展右键菜单,右键 – Create - Text File 创建一个Text文件,或者Lua文件. 关键点 获取当前选择的路径,以Assets路径开头 var sele ...
- Unity Editor已停止工作
在更换系统之后,可能会出现打开刚安装好的Unity,显示Unity Editor已停止工作,这时候我们考虑是系统win7的问题.可以在原系统上升级,也可以重新安装,升级.文中所涉及到的软件,可在右侧加 ...
- 编写 Unity Editor 插件
Editor Style Viewer 在开发过程中,我喜欢编写一些辅助的Editor插件,方便在游戏开发过程进行调试. 下面是摘自Asset Store的一个查看Unity 默认GUI样式的小工具 ...
- [Editor]Unity Editor类常用方法
Editor文档资料 Unity教程之-Unity Attribute的使用总结:http://www.unity.5helpyou.com/3550.html 利用unity3d属性来设置Inspe ...
- [cb] Unity Editor 添加右键菜单
需求 为Unity的Editor窗口添加右键菜单 实现代码 // This example shows how to create a context menu inside a custom Edi ...
- Unity Editor 编写unity插件类
在unity写了一个编辑类,基于iTweenpath插件,为了更方便的操作iTweenpath,顺便练习UnityEditor的操作,写了一个CreateiTweenPath,放在Editor文件夹中 ...
- unity Editor下自启动
[InitializeOnLoad] 加上这个特性,并且在静态构造函数里写上内容.即可在Unity启动的时候自启动这个Editor脚本
- Unity Editor Console Pro 扩展点击定位到外部工程
链接 http://blog.csdn.net/akof1314/article/details/53232981 http://forum.china.unity3d.com/thread-2689 ...
随机推荐
- BZOJ1237: [SCOI2008]配对
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1237 题目大意:你有n 个整数Ai和n 个整数Bi.你需要把它们配对,即每个Ai恰好对应一 ...
- VirtualBox中安装Android-x86详解
1.下载安装VirtualBox 官网:http://www.virtualbox.org/wiki/Downloads 2.下载Android-x86 官网:http://www.android-x ...
- 样式(Style)和主题(Theme)资源——样式资源
样式和主题资源都是用于对Android应用进行“美化”的,只要充分利用Android应用的样式和主题资源,开发者可以开发出各种风格的Android应用. 样式资源: 如果我们经常需要对 ...
- 关于IE6、IE7、IE8实现盒子阴影shadow的几个注意点
通常,我们实现盒阴影都是通过这段代码来实现的 -moz-box-shadow: 3px 3px 4px #000; -webkit-box-shadow: 3px 3px 4px #000; box- ...
- 在Delphi中隐藏程序进程
在开发某些软件的时候,为了保护程序自身,就需要用到隐藏程序进程.以下通过实例来讲解隐藏程序进程的方法: 1.创建一个新的项目 Project1 选择File,New Application.在表单Fo ...
- Delphi 常用API 函数
Delphi 常用API 函数 AdjustWindowRect 给定一种窗口样式,计算获得目标客户区矩形所需的窗口大小 AnyPopup 判断屏幕上是否存在任何弹出式窗口 ArrangeIconic ...
- --@ui-router——$state服务原版详解
$state service in module ui.router.state Description $state service is responsible for representing ...
- 网格视图(GridView)功能和用法
GridView用于在界面上按行.列分布的方式来显示多个组件.GridView和ListView有共同的父类:AbsListView,因此GridView和ListView具有很高的相似性,它们都是列 ...
- hadoop-1.x的运行实例
我的环境是hadoop-0.20.2,eclipse:SDK-3.3.2, 源数据为: Apr 23 11:49:54 hostapd: wlan0: STA 14:7d:c5:9e:fb:84 Ap ...
- sitemap.xml 的 几个东西
https://github.com/PureKrome/SimpleSitemap/wiki/Sitemap-Index-example 简单类实现 支持sitemapindex 有说明向导 ht ...