• unity回调函数范例


     1 using System.Collections;
     2 using System.Collections.Generic;
     3 using UnityEngine;
     4 
     5 public class callback : MonoBehaviour {
     6     public bool IsSuccessCallBack = true;
     7     private delegate void VoidDelegate();
     8     [ContextMenu("Build")]
     9     public void Build()
    10     {
    11         StartCoroutine(Builder(SuccessCallBack, FailureCallBack));
    12     }
    13 
    14     private IEnumerator Builder(VoidDelegate success, VoidDelegate failure)
    15     {
    16         if (!IsSuccessCallBack)
    17         {
    18             failure();
    19             yield break;
    20         }
    21         //前面是种种导致执行失败的判断
    22         success();
    23     }
    24 
    25     private void SuccessCallBack()
    26     {
    27         Debug.Log("该函数执行成功");
    28     }
    29 
    30     private void FailureCallBack()
    31     {
    32         Debug.Log("该函数执行失败");
    33     }
    34 }
  • 相关阅读:
    Python修饰符实践
    回文
    Linux下安装Qt
    Linux下安装PyQT
    Python闭包实践
    杂乱
    windows下脚本转到linux下,文件保存格式要转换
    lua table.sort的bug
    shell截取某段
    coredump
  • 原文地址:https://www.cnblogs.com/luxishi/p/6757262.html
Copyright © 2020-2023  润新知