示例#1
0
        protected void RegisterState(Vector3Event evt, UnityAction <Vector3> call, OwnershipMode mode = OwnershipMode.OnGrabbed)
        {
            if (networkMode == NetworkMode.Standalone)
            {
                evt.AddListener(call);
            }
#if USING_PHOTON
            else
            {
                PhotonVector3 photon = gameObject.GetComponent <PhotonVector3>();
                if (photon == null)
                {
                    photon = gameObject.AddComponent <PhotonVector3>();
                }

                photon.AddClient(evt, call);

                if (mode == OwnershipMode.OnGrabbed)
                {
                    onGrab.AddListener(photon.ChangeOwnership);
                }
                else
                {
                    onFocus.AddListener(photon.ChangeOwnership);
                }
            }
#endif
        }
示例#2
0
 public Elm(PhotonVector3 s, Vector3Event evt, UnityAction <Vector3> call, int w)
 {
     state = s;
     which = w;
     onChanged.AddListener(call);
     evt.AddListener(Change);
 }
示例#3
0
        public void Vector3EventTest()
        {
            var     e       = new Vector3Event();
            Vector3 counter = new Vector3();

            e.AddListener((val) => counter += val);
            Assert.AreEqual(counter, new Vector3(0, 0, 0));
            e.Invoke(new Vector3(1, 0, 0));
            Assert.AreEqual(counter, new Vector3(1, 0, 0));
            e.Invoke(new Vector3(0, 1, 0));
            e.Invoke(new Vector3(0, 0, 1));
            Assert.AreEqual(counter, new Vector3(1, 1, 1));
        }
示例#4
0
        protected void RegisterState(Vector3Event evt, UnityAction <Vector3> call)
        {
            if (networkMode == NetworkMode.Standalone)
            {
                evt.AddListener(call);
            }
#if USING_PHOTON
            else
            {
                PhotonVector3 photon = gameObject.AddComponent <PhotonVector3>();
                photon.onChanged.AddListener(call);
                evt.AddListener(photon.Change);

                if (networkMode == NetworkMode.NetworkOnGrab)
                {
                    onGrab.AddListener(photon.ChangeOwnership);
                }
                else
                {
                    onFocus.AddListener(photon.ChangeOwnership);
                }
            }
#endif
        }
示例#5
0
    public static void StartListening(string eventName, UnityAction <Vector3> listener)
    {
        UnityEvent <Vector3> thisEvent = null;

        if (instance.eventDictionaryVector3.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new Vector3Event();
            thisEvent.AddListener(listener);
            instance.eventDictionaryVector3.Add(eventName, thisEvent);
        }
    }
示例#6
0
 /// <summary>
 /// Adds a listener to this SO's event.
 /// </summary>
 /// <param name="action">Function to call on invoking the SO's event.</param>
 public void AddListener(UnityAction <Vector3> action)
 {
     OnChange.AddListener(action);
 }