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的使用的更多相关文章

  1. 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 ...

  2. Unity Editor 下创建Lua和Text文件

    预览 在Project视图中,扩展右键菜单,右键 – Create - Text File 创建一个Text文件,或者Lua文件. 关键点 获取当前选择的路径,以Assets路径开头 var sele ...

  3. Unity Editor已停止工作

    在更换系统之后,可能会出现打开刚安装好的Unity,显示Unity Editor已停止工作,这时候我们考虑是系统win7的问题.可以在原系统上升级,也可以重新安装,升级.文中所涉及到的软件,可在右侧加 ...

  4. 编写 Unity Editor 插件

    Editor Style Viewer 在开发过程中,我喜欢编写一些辅助的Editor插件,方便在游戏开发过程进行调试. 下面是摘自Asset Store的一个查看Unity 默认GUI样式的小工具 ...

  5. [Editor]Unity Editor类常用方法

    Editor文档资料 Unity教程之-Unity Attribute的使用总结:http://www.unity.5helpyou.com/3550.html 利用unity3d属性来设置Inspe ...

  6. [cb] Unity Editor 添加右键菜单

    需求 为Unity的Editor窗口添加右键菜单 实现代码 // This example shows how to create a context menu inside a custom Edi ...

  7. Unity Editor 编写unity插件类

    在unity写了一个编辑类,基于iTweenpath插件,为了更方便的操作iTweenpath,顺便练习UnityEditor的操作,写了一个CreateiTweenPath,放在Editor文件夹中 ...

  8. unity Editor下自启动

    [InitializeOnLoad] 加上这个特性,并且在静态构造函数里写上内容.即可在Unity启动的时候自启动这个Editor脚本

  9. Unity Editor Console Pro 扩展点击定位到外部工程

    链接 http://blog.csdn.net/akof1314/article/details/53232981 http://forum.china.unity3d.com/thread-2689 ...

随机推荐

  1. Java 之 HTML

    1.HTML a.定义:HTML指的是超文本标记语言 b.特点:HTML不是一种编程语言,而是一种标记语言 标记语言是一套标记标签 HTML使用标记标签来描述网页 c.HTML标签:①通常标签是成对出 ...

  2. onethink的熟悉

    2014.07.14 下载后,并安装成功! 发现一个安装的问题.安装时,无法直接成功. 修改Url 直接跳到最后一步,实现了安装.去官网查询,发现是程序的问题. 尝试构建企业官网. 首先 实现一个企业 ...

  3. 简易的AJAX工具[转]

    关键字: ajax 1.创建XMLHttpRequest对象的js文件 Ajax.js function Ajax(){    var xmlHttp=null;    if(window.XMLHt ...

  4. Struts2动态方法调用

    动态方法就是一个Action对应多个请求,减少Action的数量 1.指定method属性 <action name="addAction" method="add ...

  5. 编写PHP规则

    PHP是运行在服务器端的语言,可以动态生成html页面.这篇博客介绍它的一些编码规则. 一.基本规则 1.PHP代码总是用<?php和?>包围,例如 <?php echo " ...

  6. 关于java中的批注

    J2SE 提供的最后一个批注是 @SuppressWarnings.该批注的作用是给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默. 一点背景:J2SE 5.0 为 Java 语言增加 ...

  7. Mac下启动MySQL出现错误“the /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user”解决

    错误如下: Warring the /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user 这应该是某 ...

  8. redis 实例

    打redis模块打开官网 http://www.redis.io/  进入clients 找到PHP的选项 然后进入phpredis 这就是redis for php的扩展模块 phpize ./co ...

  9. 关于Cookie中不过滤“=”号的方法

    近来做关于Cookie的加解密工作时遇到一个问题:当用cookie.getValue()方法获取Cookie的值时,结果遇到"="号时就会自动截断,后面的值就取不到了.这是因为Ja ...

  10. 简单java web应用程序搭建与部署

    1. 准备工作 工具:tomcat.editplus.jdk.windows操作系统 操作:在windows操作系统上安装jdk.tomcat.editplus,配置JAVA_HOME,Path,CL ...