Example #1
0
        public override void OnInspectorGUI()
        {
            Vector3Event script = (Vector3Event)target;

            //Event Description
            GUILayout.BeginVertical();
            EditorGUILayout.LabelField("Event Description", EditorStyles.centeredGreyMiniLabel);
            EditorStyles.textField.wordWrap = true;
            script.EventDescription         = EditorGUILayout.TextArea(script.EventDescription, GUILayout.MinHeight(100));
            GUILayout.EndVertical();

            //Test Event Button
            GUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Test Event", EditorStyles.centeredGreyMiniLabel);
            value = EditorGUILayout.Vector3Field("Value ", value);

            if (GUILayout.Button("Raise"))
            {
                if (Application.isPlaying)
                {
                    script.Raise(value);
                }
            }
            GUILayout.EndVertical();
        }
Example #2
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
        }
Example #3
0
 public Elm(PhotonVector3 s, Vector3Event evt, UnityAction <Vector3> call, int w)
 {
     state = s;
     which = w;
     onChanged.AddListener(call);
     evt.AddListener(Change);
 }
Example #4
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));
        }
Example #5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUI.enabled = Application.isPlaying;

        Vector3Event e = target as Vector3Event;

        if (GUILayout.Button("Raise"))
        {
            e.Raise(value);
        }
    }
Example #6
0
        void Reset()
        {
            MEvent FollowUITransform = MalbersTools.GetInstance <MEvent>("Follow UI Transform");

            OnAimRayTarget = new TransformEvent();
            OnScreenCenter = new Vector3Event();

            if (FollowUITransform != null)
            {
                UnityEditor.Events.UnityEventTools.AddPersistentListener(OnAimRayTarget, FollowUITransform.Invoke);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(OnScreenCenter, FollowUITransform.Invoke);
            }
        }
Example #7
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);
        }
    }
Example #8
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
        }
Example #9
0
 private void Awake()
 {
     onMouseDown = new Vector3Event();
 }
 private void Awake()
 {
     _target       = target as Vector3Event;
     _buttonHeight = GUILayout.Height(75);
 }
Example #11
0
 public void AddClient(Vector3Event evt, UnityAction <Vector3> call)
 {
     clients.Add(new Elm(this, evt, call, clients.Count));
 }