码迷,mamicode.com
首页 > 编程语言 > 详细

Unity 扩展

时间:2015-07-16 12:01:04      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEditor;
using UnityEngine;
using System.Collections.Generic;




public class DefinesWindow : EditorWindow
{
	[MenuItem ("Window/Defines")]
	static void Init()
	{
		// Get existing open window or if none, make a new one:
		EditorWindow.GetWindow(typeof(DefinesWindow));
		
	}
	
	private string _title = "Defines Editor";
	private string _addDefine = "";
	private Vector2 _scrollPosition = Vector2.zero;
	void OnGUI ()
	{
		title = _title;
		_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, false, false);
		foreach (string define in CSharpCompilerOptions.GetDefines())
		{
			EditorGUILayout.BeginHorizontal();
			
			EditorGUILayout.LabelField(define);
			if(GUILayout.Button("Del"))
				CSharpCompilerOptions.Undefine(define);
			
			EditorGUILayout.EndHorizontal();
		}
		EditorGUILayout.EndScrollView();


		EditorGUILayout.Space();
		EditorGUILayout.BeginHorizontal();
		_addDefine = EditorGUILayout.TextField(_addDefine);
		if(GUILayout.Button("Add"))
		{
			CSharpCompilerOptions.Define(_addDefine);
		}
		
		EditorGUILayout.EndHorizontal();


		EditorGUILayout.Space();
		EditorGUILayout.BeginHorizontal();
		if(GUILayout.Button("Undefine all"))
			CSharpCompilerOptions.UndefineAll();
		if(GUILayout.Button("Reimport C# scripts"))
		{
			CSharpCompilerOptions.ReimportScripts();
		}
		EditorGUILayout.EndHorizontal();
	}
	
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Unity 扩展

标签:

原文地址:http://blog.csdn.net/lihuozhiling0101/article/details/46907063

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!