//动态添加持久化监听
SpeechInputHandler speechInput = selectObj.GetOrCreatComponent<SpeechInputHandler>();
speechInput.IsFocusRequired = false;
UnityEvent editEvent = new UnityEvent();
UnityEvent cancleEditEvent = new UnityEvent();
speechInput.Keywords = new KeywordAndResponse[]
{
new KeywordAndResponse("编辑",editEvent),
new KeywordAndResponse("取消编辑",cancleEditEvent),
};
UnityAction<bool> editDelegate = System.Delegate.CreateDelegate(typeof(UnityAction<bool>), anchorController.gameObject, "SetActive") as UnityAction<bool>;
UnityEventTools.AddBoolPersistentListener(editEvent, editDelegate, true);
UnityAction<bool> cancleDelegate = System.Delegate.CreateDelegate(typeof(UnityAction<bool>), anchorController.gameObject, "SetActive") as UnityAction<bool>;
UnityEventTools.AddBoolPersistentListener(cancleEditEvent, cancleDelegate, false);
}
//动态添加持久化监听
SpeechInputHandler speechInput = selectObj.GetOrCreatComponent<SpeechInputHandler>();
speechInput.IsFocusRequired = false;
UnityEvent editEvent = new UnityEvent();
UnityEvent cancleEditEvent = new UnityEvent();
speechInput.Keywords = new KeywordAndResponse[]
{
new KeywordAndResponse("编辑",editEvent),
new KeywordAndResponse("取消编辑",cancleEditEvent),
};
UnityAction<bool> editDelegate = System.Delegate.CreateDelegate(typeof(UnityAction<bool>), anchorController.gameObject, "SetActive") as UnityAction<bool>;
UnityEventTools.AddBoolPersistentListener(editEvent, editDelegate, true);
UnityAction<bool> cancleDelegate = System.Delegate.CreateDelegate(typeof(UnityAction<bool>), anchorController.gameObject, "SetActive") as UnityAction<bool>;
UnityEventTools.AddBoolPersistentListener(cancleEditEvent, cancleDelegate, false);
}
Debug.Log("Add AnchorContorller Success!");