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. 安卓组件service

    [转]http://blog.csdn.net/ithomer/article/details/7364024 一. Service简介 Service是android 系统中的四大组件之一(Acti ...

  2. K-Means 算法(转载)

    K-Means 算法 在数据挖掘中, k-Means 算法是一种 cluster analysis 的算法,其主要是来计算数据聚集的算法,主要通过不断地取离种子点最近均值的算法. 问题 K-Means ...

  3. @RequestBody和@ResponseBody

    @RequestBody 将HTTP请求正文转换为适合的HttpMessageConverter对象. @ResponseBody 将内容或对象作为 HTTP 响应正文返回,并调用适合HttpMess ...

  4. C++第一天学习

    代码1 #include<iostream> int main(){ int a; std::cout << "hello c++" << st ...

  5. 微信小程序来了,小程序都能做些什么

    2017年的微信大动作就是微信小程序了,到底小程序都能做些什么?这是很多人关注的热点,小程序开发对企业又有什么帮助呢?下面让厦门微信小程序开发公司来为你就分析下.       微信小程序与APP的关系 ...

  6. jquery动态加载 去除js

    !-- 这里为你提供了三种动态加载js的jquery实例代码哦,由于jquery是为用户提供方便的,所以利用jquery动态加载文件只要一句话$.getscript("test.js&quo ...

  7. CSS入门介绍

    一.背景 这里将陆续介绍前端CSS中相关知识,先介绍CSS2.1,后续会介绍CSS3的相关属性,通过该系列的文章,希望能给准备转战前端的人员一些帮助,同时也帮助自己梳理知识,文章中如有错误,欢迎指出. ...

  8. MySQL删除单列重复或多列同时重复值并保留一条

    在生产环境中,我们有的列是不允许出现重复值的,亦或是某两列不允许同时重复,但由于前端未做限制,或者没限制住,出现了单列重复值,或者两列本应组成唯一组合却也出现重复,这两种情况都是不允许的.现在由于前端 ...

  9. Cocos2d-x 多分辨率适配完全解析

    从Cocos2d-x 2.0.4开始,Cocos2d-x提出了自己的多分辨率支持方案,废弃了之前的retina相关设置接口,提出了design resolution概念. 有以下相关接口: CCEGL ...

  10. {}typeof string转为 obj json

    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.11.3/jquer ...