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 ...
随机推荐
- win7 下安装 ubuntu 16.04双系统
Ubuntu 每年发布两个版本,目前最新正式版版本也升到了 16.04.Ubuntu 16.04 开发代号为"Xenial Xerus",为第六个长期支持(LTS)版本,其主要特色 ...
- 拓扑排序(Topological)
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include<stack&g ...
- 笔记整理--玩转robots协议
玩转robots协议 -- 其他 -- IT技术博客大学习 -- 共学习 共进步! - Google Chrome (2013/7/14 20:24:07) 玩转robots协议 2013年2月8日北 ...
- scrapy bug
Issue one describle: scrapy No module named mail.smtp solution:sudo apt-get install python-twisted
- apue- chapter 1 UNIX基础知识
1.C++实现ls命令 #include<dirent.h> #include<stdlib.h> #include<iostream> #include &quo ...
- Struts2文件的下载
1.下载登录页面download.jsp 1: <%@ page language="java" contentType="text/html; charset=U ...
- 关于ExtJS必输框,多选项
必填项: //页面内传值用ID,和后台联系用name <div class="col-xs-4"> <div class= ...
- Service介绍(MediaPlayer应用)
一.Service介绍 Service类似于Windows中的服务,没有界面,只是在后台运行:而服务不能自己运行,而是需要调用Context.startService(Intent intent);或 ...
- Mac下安装cscope和ctags
Mac下默认没有cscope和ctags,太不爽了,还好可以自己编译一个放进来 一.下载地址 cscope: http://downloads.sourceforge.net/project/csco ...
- HDU2553(回溯)
N皇后问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...