示例#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();
        }
示例#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
        }
示例#3
0
 public Elm(PhotonVector3 s, Vector3Event evt, UnityAction <Vector3> call, int w)
 {
     state = s;
     which = w;
     onChanged.AddListener(call);
     evt.AddListener(Change);
 }
示例#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));
        }
示例#5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUI.enabled = Application.isPlaying;

        Vector3Event e = target as Vector3Event;

        if (GUILayout.Button("Raise"))
        {
            e.Raise(value);
        }
    }
示例#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);
            }
        }
示例#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);
        }
    }
示例#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
        }
示例#9
0
 private void Awake()
 {
     onMouseDown = new Vector3Event();
 }
 private void Awake()
 {
     _target       = target as Vector3Event;
     _buttonHeight = GUILayout.Height(75);
 }
示例#11
0
 public void AddClient(Vector3Event evt, UnityAction <Vector3> call)
 {
     clients.Add(new Elm(this, evt, call, clients.Count));
 }