本文整理汇总了C#中UnityAction.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# UnityAction.Invoke方法的具体用法?C# UnityAction.Invoke怎么用?C# UnityAction.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityAction
的用法示例。
在下文中一共展示了UnityAction.Invoke方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Display
public void Display(string text, UnityAction okAction, UnityAction cancelAction)
{
gameObject.SetActive(true);
DisplayText.text = text;
ValidButton.transform.GetChild(0).GetComponent<Text>().text = "Replay";
ValidButton.onClick.RemoveAllListeners();
ValidButton.onClick.AddListener(delegate { ValidButton.transform.GetChild(0).GetComponent<Text>().text = "Waiting..."; okAction.Invoke(); });
CancelButton.onClick.RemoveAllListeners();
CancelButton.onClick.AddListener(cancelAction);
}
示例2: DeletePlayerInternal
private IEnumerator DeletePlayerInternal(string playerName,UnityAction callback)
{
WWWForm newForm = new WWWForm();
newForm.AddField("name", playerName);
WWW w = new WWW(settings.serverAddress + "/" + settings.deletePlayer , newForm);
while (!w.isDone)
{
yield return new WaitForEndOfFrame();
}
if (w.error != null)
{
Debug.LogError(w.error);
}
if (callback != null) {
callback.Invoke();
}
Execute("OnDeletePlayer",new PlayerEventData());
}
示例3: DeletePlayerInternalPrefs
public void DeletePlayerInternalPrefs(string playerName,UnityAction callback){
string res = PlayerPrefs.GetString (playersKey);
List<string> players = new List<string> ();
string[] arr = res.Split('/');
if (arr.Length > 0)
{
for (int i = 0; i < arr.Length; i++)
{
string[] data = arr[i].Split(',');
if(data.Length > 2){
string mName = data[0];
string custom = data[1];
string level = data[2];
if(mName != playerName){
players.Add(mName+","+custom+","+level);
}
}
}
}
string allPlayers = string.Empty;
foreach (string player in players) {
allPlayers+=player+"/";
}
PlayerPrefs.SetString (playersKey, allPlayers);
if (callback != null) {
callback.Invoke();
}
Execute("OnDeletePlayer",new PlayerEventData());
}
示例4: CreatePlayerInternalPrefs
private void CreatePlayerInternalPrefs(string playerName, string custom, UnityAction<bool> callback){
string newPlayer=playerName+","+custom+",1";
string allPlayers = PlayerPrefs.GetString (playersKey);
string[] arr = allPlayers.Split('/');
if (arr.Length > 0)
{
for (int i = 0; i < arr.Length; i++)
{
string[] data = arr[i].Split(',');
if(data.Length > 2){
string mName=data[0];
if(playerName == mName){
if(callback != null){
callback.Invoke(false);
}
return;
}
}
}
}
if (callback != null) {
callback.Invoke (true);
}
PlayerPrefs.SetString (playersKey,allPlayers + "/" + newPlayer);
PlayerEventData eventData = new PlayerEventData ();
eventData.playerName = playerName;
eventData.level = 1;
eventData.custom = custom;
Execute("OnCreatePlayer",eventData);
}
示例5: CreateAccountInternal
private IEnumerator CreateAccountInternal (string username, string password, string email, UnityAction<bool> callback)
{
if (settings == null) {
yield break;
}
WWWForm newForm = new WWWForm ();
newForm.AddField ("name", username);
newForm.AddField ("password", password);
newForm.AddField ("email", email);
WWW w = new WWW(settings.serverAddress + "/" + settings.createAccount, newForm);
while (!w.isDone) {
yield return new WaitForEndOfFrame();
}
if (w.error != null) {
Debug.LogError (w.error);
}
bool res = w.text.Trim ().Equals("true");
if (callback != null) {
callback.Invoke (res);
}
AccountEventData eventData = new AccountEventData ();
eventData.serverAdress = settings.serverAddress;
User user = new User (username);
user.password = password;
eventData.user = user;
eventData.result = res;
Execute("OnCreateAccount",eventData);
}
示例6: forEachHandle
public static void forEachHandle(string path,string matchExt,UnityAction<string> handle)
{
string[] names = Directory.GetFiles(path);
string[] dirs = Directory.GetDirectories(path);
foreach (string filename in names)
{
string[] name_splits = filename.Split('.');
string ext = name_splits[name_splits.Length-1];
if (ext.Equals(matchExt))
{
handle.Invoke(filename);
}
}
foreach (string dir in dirs)
{
forEachHandle(dir, matchExt, handle);
}
}
示例7: CreatePlayerInternal
private IEnumerator CreatePlayerInternal(string username,string playerName, string custom, UnityAction<bool> callback){
WWWForm newForm = new WWWForm ();
newForm.AddField ("account", username);
newForm.AddField ("name", playerName);
newForm.AddField ("custom", custom);
newForm.AddField ("level", 1);
WWW w = new WWW (settings.serverAddress + "/"+settings.createPlayer, newForm);
while (!w.isDone) {
yield return new WaitForEndOfFrame();
}
if (w.error != null) {
Debug.LogError (w.error);
}
bool res = w.text.Trim ().Equals("true");
if (callback != null) {
callback.Invoke(res);
}
PlayerEventData eventData = new PlayerEventData ();
eventData.playerName = playerName;
eventData.level = 1;
eventData.custom = custom;
Execute("OnCreatePlayer",eventData);
}
示例8: LoadPlayersInternal
private IEnumerator LoadPlayersInternal(string username, UnityAction<PlayerEventData> callback)
{
WWWForm newForm = new WWWForm();
newForm.AddField("account", username);
WWW w = new WWW(settings.serverAddress + "/"+settings.loadPlayers, newForm);
while (!w.isDone)
{
yield return new WaitForEndOfFrame();
}
if (w.error != null)
{
Debug.LogError(w.error);
}
string res = w.text.Trim();
Debug.Log(res);
string[] arr = res.Split('/');
if (arr.Length > 0)
{
for (int i = 0; i < arr.Length; i++)
{
string[] data = arr[i].Split(',');
if(data.Length > 2){
PlayerEventData eventData = new PlayerEventData ();
eventData.playerName = data[0];
Debug.Log(data[2]);
eventData.level = int.Parse(data[2]);
eventData.custom = data[1];
Execute("OnLoadPlayer",eventData);
if (callback != null) {
callback.Invoke(eventData);
}
}
}
}
}
示例9: LoadPlayersInternalPrefs
private void LoadPlayersInternalPrefs(UnityAction<PlayerEventData> callback){
string res = PlayerPrefs.GetString (playersKey);
string[] arr = res.Split('/');
if (arr.Length > 0)
{
for (int i = 0; i < arr.Length; i++)
{
string[] data = arr[i].Split(',');
if(data.Length > 2){
PlayerEventData eventData = new PlayerEventData ();
eventData.playerName = data[0];
Debug.Log(data[2]);
eventData.level = int.Parse(data[2]);
eventData.custom = data[1];
Execute("OnLoadPlayer",eventData);
if (callback != null) {
callback.Invoke(eventData);
}
}
}
}
}
示例10: parseRichElemString
public void parseRichElemString(string content, UnityAction<string, Dictionary<string, string>> handleFunc)
{
List<string> elemStrs = new List<string>();
int startIndex = 0;
elemStrs = executeParseRichElem(elemStrs, content, startIndex);
int len = elemStrs.Count;
for (int i = 0; i < len; i++)
{
string flag = elemStrs[i].Substring(0, elemStrs[i].IndexOf(" "));
string paramStr = elemStrs[i].Substring(elemStrs[i].IndexOf(" ") + 1);
string[] paramArr = SaftSplite(paramStr,' ');
Dictionary<string, string> param = new Dictionary<string, string>();
int paramArrLen = paramArr.Length;
for (int j = 0; j < paramArrLen; j++)
{
string[] paramObj = SaftSplite(paramArr[j], '=');
string left = paramObj[0].Trim();
string right = paramObj[1].Trim();
if (right.EndsWith("\"") && right.StartsWith("\""))
{
param.Add(left, right.Trim('"'));
}
else
{
param.Add(left, right);
}
}
handleFunc.Invoke(flag, param);
}
}
示例11: parseRichDefaultString
public void parseRichDefaultString(string content, UnityAction<string, Dictionary<string, string>> specHandleFunc=null)
{
parseRichElemString(content, (flag, param) =>
{
if (flag == "lab")
{
this.insertElement(
param.ContainsKey("txt") ? param["txt"] : "",
LUtil.StringToColor(param.ContainsKey("color") ? param["color"] : defaultLabColor),
param.ContainsKey("size") ? System.Convert.ToInt32(param["size"]) : defaultLabSize,
param.ContainsKey("isUnderLine") ? System.Convert.ToBoolean(param["isUnderLine"]) : false,
param.ContainsKey("isOutLine") ? System.Convert.ToBoolean(param["isOutLine"]) : false,
LUtil.StringToColor(param.ContainsKey("outLineColor") ? param["outLineColor"] : defaultLabColor),
param.ContainsKey("data") ? param["data"] : ""
);
}else if(flag == "img")
{
this.insertElement(
param.ContainsKey("path") ? param["path"] : "",
param.ContainsKey("data") ? param["data"] : "");
}else if(flag == "anim")
{
this.insertElement(param["path"],
param.ContainsKey("fps") ? System.Convert.ToSingle(param["fps"]) : 15f,
param.ContainsKey("data") ? param["data"] : "");
}else if(flag == "newline")
{
this.insertElement(1);
}
else
{
if(specHandleFunc != null) specHandleFunc.Invoke(flag, param);
}
});
this.reloadData();
}
示例12: Open
/// <summary>
/// Open the MessageBox
/// </summary>
/// <param name="title">Title.</param>
/// <param name="text">Text.</param>
/// <param name="icon">Icon.</param>
/// <param name="result">Result.</param>
/// <param name="buttons">Buttons.</param>
public virtual void Open(string title, string text, Sprite icon, UnityAction<string> result, params string[] buttons)
{
for (int i=0; i<buttonCache.Count; i++) {
buttonCache[i].gameObject.SetActive(false);
}
if (!string.IsNullOrEmpty (title)) {
this.title.text = title;
this.title.gameObject.SetActive (true);
} else {
this.title.gameObject.SetActive(false);
}
this.text.text = text;
if(icon != null){
this.icon.sprite = icon;
this.icon.transform.parent.gameObject.SetActive(true);
}else{
this.icon.transform.parent.gameObject.SetActive(false);
}
button.gameObject.SetActive (false);
for (int i=0; i<buttons.Length; i++) {
string caption=buttons[i];
AddButton(caption).onClick.AddListener(delegate() {
result.Invoke(caption);
Close();
});
}
base.Open ();
}