- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
- 纳金币
- 52304
- 精华
- 343
|
有时为了程序的方便 我们需要对 MonoBehaviour 基础类的方法进行扩展;1.首先新建一个脚本文件:Ex.cs- using UnityEngine;
- using System.Collections;
- public static class Ex {
- /// <summary>
- /// 扩展unity 默认 MonoBehaviour 默认方法
- /// 调用时 先得继承 MonoBehaviour 然后"this.ShowMessage(message);"
- /// </summary>
- /// <param name="message"></param>
- public static void ShowMessage(this MonoBehaviour monoBehaviour,string message)
- {
- MessageWindow.showMessage(message); // MessageWindow 时自定义的一个消息处理器
- }
- }
复制代码 |
|