using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public delegate void TestDelegate();
public Action TestAction;
public Func<string> TestFunc;
private void Start()
{
TestDelegate testDelegate = () => Debug.LogError("This is Delegate Test");
testDelegate += delegate () { Debug.LogError("This is AnonymityTest"); };
TestAction = () => Debug.LogError("This is Action Test");
TestFunc = () => "This is Func Test";
TestLambda(() => Debug.LogError("This is ActionParamTest"));
TestLambda(() =>"This is FuncParamTest");
TestAnonymityLambda(delegate () { Debug.LogError("This is AnonymityTest"); });
}
public void TestLambda(Func<string> func)
{
if (func != null)
Debug.LogError(func());
}
public void TestLambda(Action action)
{
if (action != null)
action();
}
public void TestAnonymityLambda(TestDelegate testDelegate)
{
if (testDelegate != null)
testDelegate();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public delegate void TestDelegate();
public Action TestAction;
public Func<string> TestFunc;
private void Start()
{
TestDelegate testDelegate = () => Debug.LogError("This is Delegate Test");
testDelegate += delegate () { Debug.LogError("This is AnonymityTest"); };
TestAction = () => Debug.LogError("This is Action Test");
TestFunc = () => "This is Func Test";
testDelegate();
TestAction()
Debug.LogError(TestFunc());TestLambda(() => Debug.LogError("This is ActionParamTest"));
TestLambda(() =>"This is FuncParamTest");
TestAnonymityLambda(delegate () { Debug.LogError("This is AnonymityTest"); });
}
public void TestLambda(Func<string> func)
{
if (func != null)
Debug.LogError(func());
}
public void TestLambda(Action action)
{
if (action != null)
action();
}
public void TestAnonymityLambda(TestDelegate testDelegate)
{
if (testDelegate != null)
testDelegate();
}
}