Esempio n. 1
0
 private void AddEvent(EasyTouch.EvtType ev, EasyTouchTrigger t)
 {
     EasyTouchTrigger.EasyTouchReceiver r = new EasyTouchTrigger.EasyTouchReceiver();
     r.enable     = true;
     r.restricted = true;
     r.eventName  = ev;
     r.gameObject = t.gameObject;
     t.receivers.Add(r);
 }
 // Token: 0x06000286 RID: 646 RVA: 0x0000BA00 File Offset: 0x00009E00
 public void AddTrigger(EasyTouch.EvtType ev)
 {
     EasyTouchTrigger.EasyTouchReceiver easyTouchReceiver = new EasyTouchTrigger.EasyTouchReceiver();
     easyTouchReceiver.enable        = true;
     easyTouchReceiver.restricted    = true;
     easyTouchReceiver.eventName     = ev;
     easyTouchReceiver.gameObject    = null;
     easyTouchReceiver.otherReceiver = false;
     easyTouchReceiver.name          = "New trigger";
     this.receivers.Add(easyTouchReceiver);
     if (Application.isPlaying)
     {
         this.UnsubscribeEasyTouchEvent();
         this.SubscribeEasyTouchEvent();
     }
 }
Esempio n. 3
0
    public override void OnInspectorGUI()
    {
        EasyTouchTrigger t = (EasyTouchTrigger)target;

        string[] eventNames = Enum.GetNames(typeof(EasyTouch.EvtType));
        eventNames[0] = "Add new event";

        #region Event properties
        GUILayout.Space(5f);
        for (int i = 1; i < eventNames.Length; i++)
        {
            EasyTouch.EvtType ev = (EasyTouch.EvtType)Enum.Parse(typeof(EasyTouch.EvtType), eventNames[i]);
            int result           = t.receivers.FindIndex(
                delegate(EasyTouchTrigger.EasyTouchReceiver e){
                return(e.eventName == ev);
            }
                );

            if (result > -1)
            {
                TriggerInspector(ev, t);
            }
        }
        #endregion

        #region Add Event
        GUI.backgroundColor = Color.green;
        int index = EditorGUILayout.Popup("", 0, eventNames, "Button");
        GUI.backgroundColor = Color.white;

        if (index != 0)
        {
            //AddEvent((EasyTouch.EventName)Enum.Parse( typeof(EasyTouch.EventName), eventNames[index]),t );
            t.AddTrigger((EasyTouch.EvtType)Enum.Parse(typeof(EasyTouch.EvtType), eventNames[index]));
            EditorPrefs.SetBool(eventNames[index], true);
        }
        #endregion

        if (GUI.changed)
        {
            EditorUtility.SetDirty(t);
                        #if UNITY_5_3_OR_NEWER
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        #endif
        }
    }
Esempio n. 4
0
        private bool IsRecevier4(EasyTouch.EvtType evnt)
        {
            int result = receivers.FindIndex(
                delegate(EasyTouchTrigger.EasyTouchReceiver e){
                return(e.eventName == evnt);
            }
                );

            if (result > -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // Token: 0x0600028A RID: 650 RVA: 0x0000BE24 File Offset: 0x0000A224
        private bool IsRecevier4(EasyTouch.EvtType evnt)
        {
            int num = this.receivers.FindIndex((EasyTouchTrigger.EasyTouchReceiver e) => e.eventName == evnt);

            return(num > -1);
        }
        // Token: 0x06000289 RID: 649 RVA: 0x0000BAB0 File Offset: 0x00009EB0
        private void TriggerScheduler(EasyTouch.EvtType evnt, Gesture gesture)
        {
            foreach (EasyTouchTrigger.EasyTouchReceiver easyTouchReceiver in this.receivers)
            {
                if (easyTouchReceiver.enable && easyTouchReceiver.eventName == evnt && ((easyTouchReceiver.restricted && ((gesture.pickedObject == base.gameObject && easyTouchReceiver.triggerType == EasyTouchTrigger.ETTType.Object3D) || (gesture.pickedUIElement == base.gameObject && easyTouchReceiver.triggerType == EasyTouchTrigger.ETTType.UI))) || (!easyTouchReceiver.restricted && (easyTouchReceiver.gameObject == null || (easyTouchReceiver.gameObject == gesture.pickedObject && easyTouchReceiver.triggerType == EasyTouchTrigger.ETTType.Object3D) || (gesture.pickedUIElement == easyTouchReceiver.gameObject && easyTouchReceiver.triggerType == EasyTouchTrigger.ETTType.UI)))))
                {
                    GameObject gameObject = base.gameObject;
                    if (easyTouchReceiver.otherReceiver && easyTouchReceiver.gameObjectReceiver != null)
                    {
                        gameObject = easyTouchReceiver.gameObjectReceiver;
                    }
                    switch (easyTouchReceiver.parameter)
                    {
                    case EasyTouchTrigger.ETTParameter.None:
                        gameObject.SendMessage(easyTouchReceiver.methodName, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Gesture:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Finger_Id:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.fingerIndex, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Touch_Count:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.touchCount, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Start_Position:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.startPosition, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Position:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.position, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Delta_Position:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.deltaPosition, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Swipe_Type:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.swipe, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Swipe_Length:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.swipeLength, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Swipe_Vector:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.swipeVector, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Delta_Pinch:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.deltaPinch, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.Twist_Anlge:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.twistAngle, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.ActionTime:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.actionTime, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.DeltaTime:
                        gameObject.SendMessage(easyTouchReceiver.methodName, gesture.deltaTime, SendMessageOptions.DontRequireReceiver);
                        break;

                    case EasyTouchTrigger.ETTParameter.PickedObject:
                        if (gesture.pickedObject != null)
                        {
                            gameObject.SendMessage(easyTouchReceiver.methodName, gesture.pickedObject, SendMessageOptions.DontRequireReceiver);
                        }
                        break;

                    case EasyTouchTrigger.ETTParameter.PickedUIElement:
                        if (gesture.pickedUIElement != null)
                        {
                            gameObject.SendMessage(easyTouchReceiver.methodName, gesture.pickedObject, SendMessageOptions.DontRequireReceiver);
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 7
0
    private void TriggerInspector(EasyTouch.EvtType ev, EasyTouchTrigger t)
    {
        bool folding = EditorPrefs.GetBool(ev.ToString());

        folding = HTGuiTools.BeginFoldOut(ev.ToString(), folding, false);
        EditorPrefs.SetBool(ev.ToString(), folding);

        if (folding)
        {
            HTGuiTools.BeginGroup();

            int i = 0;
            while (i < t.receivers.Count)
            {
                if (t.receivers[i].eventName == ev)
                {
                    GUI.color = new Color(0.8f, 0.8f, 0.8f, 1);
                    HTGuiTools.BeginGroup(5);
                    GUI.color = Color.white;


                    EditorGUILayout.BeginHorizontal();
                    t.receivers[i].enable = HTGuiTools.Toggle("Enable", t.receivers[i].enable, 55, true);
                    t.receivers[i].name   = EditorGUILayout.TextField("", t.receivers[i].name, GUILayout.MinWidth(130));

                    // Delete
                    GUILayout.FlexibleSpace();
                    if (HTGuiTools.Button("X", Color.red, 19))
                    {
                        t.receivers[i] = null;
                        t.receivers.RemoveAt(i);
                        EditorGUILayout.EndHorizontal();
                        return;
                    }
                    EditorGUILayout.EndHorizontal();


                    EditorGUILayout.Space();

                    // Restriced
                    //t.receivers[i].restricted = HTGuiTools.Toggle("Restricted to gameobject",t.receivers[i].restricted,true);

                    t.receivers[i].triggerType = (EasyTouchTrigger.ETTType)EditorGUILayout.EnumPopup("Testing on", t.receivers[i].triggerType);

                    EditorGUILayout.BeginHorizontal();
                    t.receivers[i].restricted = EditorGUILayout.Toggle("", t.receivers[i].restricted, (GUIStyle)"Radio", GUILayout.Width(15));
                    EditorGUILayout.LabelField("Only if on me (requiered a collider)");
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    t.receivers[i].restricted = !EditorGUILayout.Toggle("", !t.receivers[i].restricted, (GUIStyle)"Radio", GUILayout.Width(15));
                    EditorGUILayout.LabelField("All the time, or other object");
                    EditorGUILayout.EndHorizontal();

                    if (!t.receivers[i].restricted)
                    {
                        t.receivers[i].gameObject = (GameObject)EditorGUILayout.ObjectField("Other object", t.receivers[i].gameObject, typeof(GameObject), true);
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    t.receivers[i].otherReceiver = HTGuiTools.Toggle("Other receiver", t.receivers[i].otherReceiver, true);
                    if (t.receivers[i].otherReceiver)
                    {
                        t.receivers[i].gameObjectReceiver = (GameObject)EditorGUILayout.ObjectField("Receiver", t.receivers[i].gameObjectReceiver, typeof(GameObject), true);
                    }

                    // Method Name
                    EditorGUILayout.BeginHorizontal();
                    t.receivers[i].methodName = EditorGUILayout.TextField("Method name", t.receivers[i].methodName);

                    // Methode helper
                    string[] mNames = null;
                    if (!t.receivers[i].otherReceiver || (t.receivers[i].otherReceiver && t.receivers[i].gameObjectReceiver == null))
                    {
                        mNames = GetMethod(t.gameObject);
                    }
                    else if (t.receivers[i].otherReceiver && t.receivers[i].gameObjectReceiver != null)
                    {
                        mNames = GetMethod(t.receivers[i].gameObjectReceiver);
                    }

                    int index = EditorGUILayout.Popup("", -1, mNames, "Button", GUILayout.Width(20));
                    if (index > -1)
                    {
                        t.receivers[i].methodName = mNames[index];
                    }
                    EditorGUILayout.EndHorizontal();


                    // Parameter
                    t.receivers[i].parameter = (EasyTouchTrigger.ETTParameter)EditorGUILayout.EnumPopup("Parameter to send", t.receivers[i].parameter);

                    HTGuiTools.EndGroup();
                }
                i++;
            }
        }
        else
        {
            HTGuiTools.BeginGroup();
        }
        HTGuiTools.EndGroup(false);

        if (!GUILayout.Toggle(true, "+", "ObjectPickerTab"))
        {
            t.AddTrigger(ev);
        }

        GUILayout.Space(5f);
    }