先来看下效果图,图中点击 Cube(EventDispatcher),Sphere(EventListener)以及 Capsule(EventListener)会做出相应的变化,例子中的对象相互之间没有引用,也没有父子关系. Demo 事件触发者(EventDispatcher)CubeObject.cs,挂载在 Cube 对象上 using UnityEngine; using System.Collections; public class CubeObject : MonoBehavio
全局维护一个字典,字典中的key为字符串或者自定义类型,value为委托, using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public delegate void CallBack(); public delegate void CallBack<T>(T t); public delegate void CallBack<T, D>(T t,
TextView都有跑马灯的效果,如果说让你去监听跑马灯效果的执行,我觉得这个需求有点二了,但是也要实现. 思路: 1.自定义View 继承TextView 这种方法过于麻烦,只是监听一个跑马灯而已. 2.自定义SPan.简单好用,扩展TextView的功能. 关键代码如下: @Override public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, in