1. BeginToggleGroup()
BeginToggleGroup函数是定义了一个控制范围,可以控制该范围中的GUI是否启用,看下演示代码:
[code]csharpcode:
using UnityEngine;
using System.Collections;
using UnityEditor; // 编辑器命名空间的引用
public class Editor2 : EditorWindow // 编辑器类
{
bool _toggle;
Color _color;
string _string;
AnimationCurve _animationCurve = new AnimationCurve();
[MenuItem("EditorDemo/CreateWindow")] // 在编辑器中添加一个菜单
static void CreateWindow() // 下面这个函数必须是***静态的***
{
// 在这里面创建窗口
EditorWindow.GetWindow(typeof(Editor2), false, "EditorWindow", true);
}
void OnGUI()
{
_toggle = EditorGUILayout.BeginToggleGroup("Toggle", _toggle); // 组开始
_color = EditorGUILayout.ColorField("Color", _color); // 组中的内容
_string = EditorGUILayout.TextField("Text", _string);
EditorGUILayout.EndToggleGroup(); // 组结束
_animationCurve = EditorGUILayout.CurveField("AnimationCurve", _animationCurve); // 组外的内容
}
}




