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");
            }
        }
    }
Exemple #3
0
    // 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);
    }
Exemple #4
0
    public void Test()
    {
        TestEvent += (_, s) => Console.WriteLine(s);
        TestEvent += (_, s) => Console.WriteLine(s + "qwe");
        Delegate   = TestEvent;

        TestEvent?.Invoke(this, Delegate?.ToString());
    }
Exemple #5
0
 public void RaiseTestEvent()
 {
     Console.WriteLine("**********");
     Console.WriteLine("Raising TestEvent");
     // Event Invoked
     TestEvent?.Invoke();
     Console.WriteLine("**********");
 }
Exemple #6
0
    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);
 }
Exemple #8
0
        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();
        }
Exemple #9
0
        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);
 }
Exemple #12
0
 public void InvokeEvent()
 {
     TestEvent?.Invoke();
 }
Exemple #13
0
 public void Event()
 {
     TestEvent += (s, e) => Assert.AreEqual(nameof(CallerQuerierTest), CallerQuerier.GetCurrent().TypeName);
     TestEvent?.Invoke(this, new EventArgs());
 }
Exemple #14
0
 public void CallEvent()
 {
     TestEvent?.Invoke(this, EventArgs.Empty);
 }
Exemple #15
0
 private void Awake()
 {
     _event.Invoke(message, parameter);
 }
Exemple #16
0
 public void RaiseEvent()
 {
     TestEvent?.Invoke();
 }
Exemple #17
0
 public void CallEvent()
 {
     TestEvent?.Invoke(this, new EventArgsTest(5));
 }
Exemple #18
0
 internal void InvokeTestEvent()
 {
     TestEvent?.Invoke(this, new CustomEventArgs {
         Data = "test"
     });
 }
Exemple #19
0
 private void InstanceMethod()
 {
     TestEvent.Invoke();
 }
 public void FireTestEvent(int item)
 {
     TestEvent?.Invoke(item);
 }
Exemple #21
0
 public void OnTestEvent()
 {
     TestEvent?.Invoke(this, null);
 }
 public void Fire()
 {
     TestEvent?.Invoke();
 }
Exemple #23
0
 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);
 }
Exemple #27
0
 public void RiseTestEvent(object sender, EventArgs eventArgs)
 {
     TestEvent?.Invoke(sender, eventArgs);
 }
Exemple #28
0
 public void TestEventInvoke()
 {
     TestEvent += EventHandler;
     TestEvent.Invoke();
 }
Exemple #29
0
 protected virtual void OnTestEvent()
 {
     TestEvent?.Invoke(this, EventArgs.Empty);
 }
Exemple #30
0
 protected virtual void OnTestEvent(TestEventArgs e) => TestEvent?.Invoke(this, e);