GUI实现,如下:

按“G”键开始新手引导

代码如下:

using UnityEngine;
using System.Collections; public class OkButton : GUIBase {
/// <summary>
/// 按钮图片
/// </summary>
public Texture2D OKBTN_a;
public Texture2D OKBTN_b;
/// <summary>
/// 引导图片
/// </summary>
public Texture2D HoleTexture; private GUIStyle OKBTNStyle;
private GUIStyle _defaultStyle;
// Use this for initialization
public override void Start () {
base.Start();
OKBTNStyle = new GUIStyle();
_defaultStyle = new GUIStyle();
_defaultStyle.padding = new RectOffset(, , , );
_defaultStyle.border = new RectOffset(, , , );
if (OKBTN_a == null)
{
OKBTN_a = Resources.Load("OKBTN/OK_a") as Texture2D;
OKBTNStyle.normal.background = OKBTN_a;
}
if (OKBTN_b == null)
{
OKBTN_b = Resources.Load("OKBTN/OK_b") as Texture2D;
OKBTNStyle.active.background = OKBTN_b;
}
if (HoleTexture == null)
HoleTexture = Resources.Load("OKBTN/okfight") as Texture2D;
} // Update is called once per frame
public override void Update () {
base.Update();
}
private bool _isGuider = false;
void LateUpdate()
{
if (Input.GetKeyDown(KeyCode.G))
{
_isGuider = true;
}
}
public override void OnGUI()
{
base.OnGUI();
if (_isGuider) //引导
{
GUI.DrawTexture(new Rect(, , , ), HoleTexture);
Rect rect = new Rect(, , , );
OkButton.AddHole(rect, _defaultStyle);
if (Event.current.type == EventType.MouseUp)
{
if (rect.Contains(Event.current.mousePosition))
{
StartCoroutine(disCatch());
}
}
}
if (GUI.Button(new Rect(, , , ), "", OKBTNStyle))
{
print("Click OKBTN");
_isGuider = false;
}
if (GUI.Button(new Rect(, , , ), "", OKBTNStyle))
{
print("Click Other");
} }
/// <summary>
/// 另外线程处理
/// </summary>
/// <returns></returns>
IEnumerator disCatch()
{
//开一个线程处理要处理的事
yield return ;
}
/// <summary>
/// 在界面上面开孔,只有此处可以点击,其余的地方屏蔽用户点击,即在该按钮四周加其他按钮,先加的按钮会在上层。后加的按钮被屏蔽。
/// </summary>
/// <param name="rect"></param>
public static void AddHole(Rect rect, GUIStyle style)
{
GUI.Button(new Rect(, , GUIBase.DesignStageWidth, rect.y), "", style);//上面的button
GUI.Button(new Rect(, rect.yMax, GUIBase.DesignStageWidth, GUIBase.DesignStageHeight - rect.yMax), "", style); //下边的button
GUI.Button(new Rect(, rect.y, rect.x, rect.height), "", style);//左边
GUI.Button(new Rect(rect.xMax, rect.y, GUIBase.DesignStageWidth - rect.xMax, rect.height), "", style);//右边
}
}

最新文章

  1. STC12C5A60S2笔记1(管脚定义)
  2. Android中过场动画
  3. Folder Recursion with C#
  4. C#流总结(文件流、内存流、网络流、BufferedStream、StreamReader/StreamWriter、TextReader/TextWriter)
  5. GridView编辑删除操作
  6. Unity3D流行的游戏开发人员构建高速检查站系统
  7. pdf.js实现在HTML下直接浏览pdf文档,无需插件即可实现
  8. cocos2dx - 在MFC中使用cocos2dx
  9. 前端css常用class命名id命名
  10. 如何使用GitHub
  11. Java进阶(三十四)Integer与int的种种比较你知道多少?
  12. 解决pycharm问题:module &#39;pip&#39; has no attribute &#39;main&#39;
  13. Lucene 4.X 全套教程
  14. Spring Boot Actuator的端点
  15. tcpdump命令(转载)
  16. ABAP-2-会计凭证批量数据导入本地ACCESS
  17. 【c++基础】如何获取工程项目当前路径
  18. Received non-all-whitespace CHARACTERS or CDATA event in nextTag(). ,无法整齐打印验证错误。 解析XML文档出现的问题
  19. PHP遍历目录返回统计目录大小实例
  20. Winform DatagridviewcomboboxColumn Disable Style

热门文章

  1. Java基础知识强化之网络编程笔记18:Android网络通信之 使用HttpClient的Post / Get 方式读取网络数据(基于HTTP通信技术)
  2. javascript笔记06:类的创建
  3. Visual Studio 2012 Web一键式发布
  4. 深入浅出ECharts系列 (二) 折线图
  5. [转]Install App to SD
  6. 【区间选点问题】uva 10148 - Advertisement
  7. 怎样在CentOS 7.0上安装和配置VNC服务器
  8. Unity3D 之连按移动加速
  9. win32项目设置窗口全屏
  10. HTML5标签及使用方法描述