//注册 如果已经注册返回FALSE public bool RigisterSensor <T>(TouchTile <T> s) where T : InputEvent, new() { if (s != null) { if (_eventMap.ContainsKey(s.EventID)) { List <BaseInputSensor> bs = _eventMap[s.EventID]; if (bs.Contains(s)) { return(false); } else { bs.Add(s); bs.Sort(); //Debug.Log("add list " + bs.Count + " priority is " + s.Priority); return(true); } } else { List <BaseInputSensor> bs = new List <BaseInputSensor>(); _eventMap.Add(s.EventID, bs); Debug.Log("add map " + s.EventID); bs.Add(s); bs.Sort(); Debug.Log("add list " + bs.Count + " priority is " + s.Priority); return(true); } } return(false); }
//反注册 如果没有注册返回false public bool UnRigisterSensor <T>(TouchTile <T> s) where T : InputEvent, new() { if (s != null) { if (_eventMap.ContainsKey(s.EventID)) { List <BaseInputSensor> bs = _eventMap[s.EventID]; return(bs.Remove(s)); } } return(false); }