1.首先定义一个需要控制数值的类,类中定义若干个变量

using UnityEngine;
using System.Collections;

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. // This is not an editor script.
  5. public class MyPlayer : MonoBehaviour {
  6. public int Jump;
  7.  
  8. void Update () {
  9. // Update logic here...
  10. }
  11. }

2.创建Editor文件夹

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

现附上代码下面说明

  1. using UnityEditor;
  2. using UnityEngine;
  3.  
  4. [CustomEditor(typeof(RenControll))]
  5. [CanEditMultipleObjects]
  6. public class CatEditor : Editor
  7. {
  8.  
  9. SerializedProperty _Jump;
  10.  
  11. void OnEnable()
  12. {
  13. // Setup the SerializedProperties.
  14. _Jump = serializedObject.FindProperty("Jump");
  15.  
  16. }
  17.  
  18. public override void OnInspectorGUI()
  19. {
  20. // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
  21. serializedObject.Update();
  22.  
  23. EditorGUILayout.IntSlider(_Jump, 0, 100, new GUIContent("跳跃次数"));
  24.  
  25. // Only show the armor progress bar if all the objects have the same armor value:
  26. if (!_Jump.hasMultipleDifferentValues)
  27. ProgressBar(_Jump.intValue / 100.0f, "Attack");
  28.  
  29. // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
  30. serializedObject.ApplyModifiedProperties();
  31. }
  32.  
  33. // Custom GUILayout progress bar.
  34. void ProgressBar(float value, string label)
  35. {
  36. // Get a rect for the progress bar using the same margins as a textfield:
  37. Rect rect = GUILayoutUtility.GetRect(18, 18, "TextField");
  38. EditorGUI.ProgressBar(rect, value, label);
  39. EditorGUILayout.Space();
  40. }
  41.  
  42. }

  

  1. [CustomEditor(typeof(RenControll))]找到我们游戏中用到的主体类.
  1. _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. cocos2d动作讲解

    从本章开始,我们开始讲解cocos2d-x库的动作(Action).游戏的世界是一个动态的世界:无论是主角精灵还是NPC精灵都处于不断的运动当中,甚至是背景中漂流的树叶,随风而动的小草.这些明显的或者 ...

  2. web前端面试第三波~

    快来测试测试自己掌握能力吧! 1. class.forname的作用?为什么要用? 1).获取Class对象的方式:类名.class.对象.getClass().Class.forName(" ...

  3. UVa 10176 - Ocean Deep ! - Make it shallow !!

    题目大意:判断一个很大的二进制能否被131071整除.在二进制转十进制的过程中不断取模,最后判断结果是否是0就可以了. #include <cstdio> #include <cst ...

  4. Xcode 之 snippet 代码重用

    1. 选中代码 2. 拖入xcode 右下侧的 snippet 区域 3. 修改名称 4. 修改快捷输入 (shortcut) 5. <#content#> ,可选修改项

  5. robotium从入门到放弃 三 基于apk的自动化测试

      1.apk重签名   在做基于APK的自动化测试的过程中,需要确保的一点是,被测试的APK必须跟测试项目具有相同的签名,那怎么做才能确保两者拥有相同的签名呢?下面将给出具体的实现方法. 首先将被测 ...

  6. 在 AngularJS 中将 XML 转换为 JSON

    在这篇文章中,我们将谈谈如何在Angular JS中将XML文件转换为JSON.大家都知道Angular JS是开发应用程序的JavaScript框架.所以基本上Angular  JS期望得 到的响应 ...

  7. Delphi隐藏进程

    interface function MyHideProcess: Boolean; implementation uses Windows, Classes, AclAPI, accCtrl; ty ...

  8. 在DFS和BFS中一般情况可以不用vis[][]数组标记

    开始学dfs 与bfs 时一直喜欢用vis[][]来标记有没有访问过, 现在我觉得没有必要用vis[][]标记了 看代码 用'#'表示墙,'.'表示道路 if(所有情况都满足){ map[i][j]= ...

  9. Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer

    Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1.  Start heka ...

  10. emmet学习笔记

    Emment语法使用:按table键的结果1.初始化:(HTML文档需要包含一些固定的标签,比如<html>.<head>.<body>等). html:或! :用 ...