internal void InvokeEvent() { if (TestEvent != null) { TestEvent.Invoke(); } }
public event Action <int, string> ActionEventExample; //using System library is needed for Action type events // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.E)) { testEvent.Invoke("Unity Event Message"); } if (Input.GetKeyDown(KeyCode.G)) { if (GenericEventExample != null) { GenericEventExample(7, "Cristiano Ronaldo"); } else { Debug.Log("No listeners found for out event"); } } if (Input.GetKeyDown(KeyCode.A)) { if (ActionEventExample != null) { ActionEventExample(10, "Leo Messi"); } else { Debug.Log("No listeners found for this event"); } } }
// Use this for initialization void Start() { Debug.LogError(int.Parse("1111111111")); TestHandler testHandler = new TestHandler(TestDelegate); testHandler.Invoke("lzd", 10); //事件注册委托 TestEvent += testHandler; TestEvent.Invoke("lzd", 10); TestDelegateHandler = TestEventHandler; gameObject.AddComponent <MeshFilter>(); gameObject.AddComponent <MeshRenderer>(); Mesh mesh = GetComponent <MeshFilter>().mesh; mesh.Clear(); mesh.vertices = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 1, 0) }; mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 1) }; mesh.triangles = new int[] { 0, 1, 2 }; Vector3 vec = transform.position - enemyTransform.position; transform.Translate(vec); }
public void Test() { TestEvent += (_, s) => Console.WriteLine(s); TestEvent += (_, s) => Console.WriteLine(s + "qwe"); Delegate = TestEvent; TestEvent?.Invoke(this, Delegate?.ToString()); }
public void RaiseTestEvent() { Console.WriteLine("**********"); Console.WriteLine("Raising TestEvent"); // Event Invoked TestEvent?.Invoke(); Console.WriteLine("**********"); }
public async System.Threading.Tasks.Task TestAsync() { TestEvent += (_, s) => Console.WriteLine(s); TestEvent += (_, s) => Console.WriteLine(s + "qwe"); Delegate = TestEvent; TestEvent?.Invoke(this, Delegate?.ToString()); await System.Threading.Tasks.Task.CompletedTask; }
public void GoodRecieving(Product product) { products.Add(product); NewProductRecieved(null, new GoodsInfoEventArgs() { Cost = product.Cost, ProductName = product.ProductName }); TestEvent?.Invoke(product.Cost); }
static void Main(string[] args) { int?a = null; int b = a ?? 10; Console.WriteLine(b); OnTestEvent(); TestEvent?.Invoke(null, null); Console.WriteLine("press any key to continue..."); Console.ReadKey(); }
public void GoodReciving(Product product) { products.Add(product); NewProductRecived(null, new GoodsInfoEventArgs() { Cost = product.Cost, ProductName = product.ProductName }); TestEvent?.Invoke(product.Cost); TestObj?.Invoke(null, new List <int>() { 1, 2, 3 }); }
public void TestExecute() { int executeCounter = 0; var eventFiringScheduler = new EventFiringScheduler(); eventFiringScheduler.LifeCycleEvent += Executed; eventFiringScheduler.Start(); TestEvent += EmptyFire; Assert.AreEqual(0, executeCounter); TestEvent?.Invoke(this, EventArgs.Empty); Assert.AreEqual(1, executeCounter); TestEvent?.Invoke(this, EventArgs.Empty); Assert.AreEqual(2, executeCounter); eventFiringScheduler.Stop(); Assert.AreEqual(2, executeCounter); TestEvent -= EmptyFire; void Executed(object sender, SchedulerLifeCycleEventArgs args) { if (args.EventType == SchedulerLifeCycleEventType.Execute) { executeCounter++; } } void EmptyFire(object sender, EventArgs args) { eventFiringScheduler.Fire(sender, args, null); } }
public void RaiseTestEvent() { TestEvent?.Invoke(this, EventArgs.Empty); }
public void InvokeEvent() { TestEvent?.Invoke(); }
public void Event() { TestEvent += (s, e) => Assert.AreEqual(nameof(CallerQuerierTest), CallerQuerier.GetCurrent().TypeName); TestEvent?.Invoke(this, new EventArgs()); }
public void CallEvent() { TestEvent?.Invoke(this, EventArgs.Empty); }
private void Awake() { _event.Invoke(message, parameter); }
public void RaiseEvent() { TestEvent?.Invoke(); }
public void CallEvent() { TestEvent?.Invoke(this, new EventArgsTest(5)); }
internal void InvokeTestEvent() { TestEvent?.Invoke(this, new CustomEventArgs { Data = "test" }); }
private void InstanceMethod() { TestEvent.Invoke(); }
public void FireTestEvent(int item) { TestEvent?.Invoke(item); }
public void OnTestEvent() { TestEvent?.Invoke(this, null); }
public void Fire() { TestEvent?.Invoke(); }
public void Fire() { TestEvent?.Invoke(null, new TestClass2()); }
public void TriggerEvent(TestTransmissionInfo transmissionInfo, string param) { TestEvent?.Invoke(transmissionInfo, param); }
protected virtual void OnTestOperationEvent(RobotTestEventArguments e) { TestEvent?.Invoke(this, e); }
public void RaiseTestEvent(int x) { TestEvent?.Invoke(x); }
public void RiseTestEvent(object sender, EventArgs eventArgs) { TestEvent?.Invoke(sender, eventArgs); }
public void TestEventInvoke() { TestEvent += EventHandler; TestEvent.Invoke(); }
protected virtual void OnTestEvent() { TestEvent?.Invoke(this, EventArgs.Empty); }
protected virtual void OnTestEvent(TestEventArgs e) => TestEvent?.Invoke(this, e);