1
This commit is contained in:
30
Unity/Scripts/Utility/Tests/GenericEventTest.cs
Normal file
30
Unity/Scripts/Utility/Tests/GenericEventTest.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using Newtonsoft.Json;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using BITKit.IO;
|
||||
using System.Text;
|
||||
namespace BITKit
|
||||
{
|
||||
public class GenericEventTest
|
||||
{
|
||||
[Test]
|
||||
public void TestInvokeByType()
|
||||
{
|
||||
GenericEvent genericEvent = new();
|
||||
genericEvent.AddListener<string>(OnGetString);
|
||||
|
||||
genericEvent.Invoke<string>("Value 123");
|
||||
genericEvent.Invoke(typeof(string).Name, "Value 321" as object);
|
||||
void OnGetString(string value)
|
||||
{
|
||||
Debug.Log($"事件回调:{value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user