using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CallbackUsingDelegateDemo : MonoBehaviour {
public delegate void WorkCompletedCallBack(string result);
public void DoWork(WorkCompletedCallBack callback){
bool isWorkDone;
//do work here
isWorkDone = true;
if (isWorkDone)
callback ("yes work done successfully...");
else
callback ("sorry work not done...");
}
void Start(){
WorkCompletedCallBack workResultCallback = ShowWorkResult;
DoWork (workResultCallback);
}
//this is the callback which is called when the work is done in DoWork()
public void ShowWorkResult(string result){
Debug.Log (result);
}
}