Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- using System.Collections;
- [System.Serializable]
- public class Buttons
- {
- public string ButtonName;
- public int ButtonID;
- public ButtonType ButtonAction;
- [System.Serializable]
- public enum ButtonType
- {
- Hold,
- Up,
- Down
- }
- public Buttons(string name, int id)
- {
- ButtonName = name;
- ButtonID = id;
- }
- public Buttons()
- {
- }
- }
- public class ControllerDemo : MonoBehaviour {
- public Buttons[] xBox360;
- // Use this for initialization
- void Start ()
- {
- }
- void Update () {
- // ---AXIS---
- // Right Trigger (RT) Left Trigger (LT)
- if (Input.GetAxis("TriggerLeft") != 0)
- {
- Debug.Log("Left: " + Input.GetAxis("TriggerLeft"));
- }
- if (Input.GetAxis("TriggerRight") != 0)
- {
- Debug.Log("Right:" + Input.GetAxis("TriggerRight"));
- }
- //Left Stick
- if (Input.GetAxis("Horizontal") != 0)
- {
- Debug.Log("Horizontal: " + Input.GetAxis("Horizontal"));
- }
- if (Input.GetAxis("Vertical") != 0)
- {
- Debug.Log("Vertical: " + Input.GetAxis("Vertical"));
- }
- if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) // Both
- {
- }
- // Right Stick
- if (Input.GetAxis("Horizontal2") != 0)
- {
- Debug.Log("Horizontal2: " + Input.GetAxis("Horizontal2"));
- }
- if (Input.GetAxis("Vertical2") != 0)
- {
- Debug.Log("Vertical2: " + Input.GetAxis("Vertical2"));
- }
- if (Input.GetAxis("Horizontal2") != 0 || Input.GetAxis("Vertical2") != 0) // Both
- {
- }
- // D-Pad
- if (Input.GetAxis("Horizontal3") != 0)
- {
- Debug.Log("Horizontal3: " + Input.GetAxis("Horizontal3"));
- }
- if (Input.GetAxis("Vertical3") != 0)
- {
- Debug.Log("Vertical3: " + Input.GetAxis("Vertical3"));
- }
- if (Input.GetAxis("Horizontal3") != 0 || Input.GetAxis("Vertical3") != 0) // Both
- {
- }
- //---Buttons---
- // Button: A
- if (Input.GetButton("A"))
- {
- }
- if (Input.GetButtonDown("A"))
- {
- }
- if (Input.GetButtonUp("A"))
- {
- }
- // Button: B
- if (Input.GetButton("B"))
- {
- }
- if (Input.GetButtonDown("B"))
- {
- }
- if (Input.GetButtonUp("B"))
- {
- }
- // Button: X
- if (Input.GetButton("X"))
- {
- }
- if (Input.GetButtonDown("X"))
- {
- }
- if (Input.GetButtonUp("X"))
- {
- }
- // Button: Y
- if (Input.GetButton("Y"))
- {
- }
- if (Input.GetButtonDown("Y"))
- {
- }
- if (Input.GetButtonUp("Y"))
- {
- }
- // Button: LB
- if (Input.GetButton("LB"))
- {
- }
- if (Input.GetButtonDown("LB"))
- {
- }
- if (Input.GetButtonUp("LB"))
- {
- }
- // Button: RB
- if (Input.GetButton("RB"))
- {
- }
- if (Input.GetButtonDown("RB"))
- {
- }
- if (Input.GetButtonUp("RB"))
- {
- }
- // Button: LAP
- if (Input.GetButton("LAP"))
- {
- }
- if (Input.GetButtonDown("LAP"))
- {
- }
- if (Input.GetButtonUp("LAP"))
- {
- }
- // Button: RAP
- if (Input.GetButton("RAP"))
- {
- }
- if (Input.GetButtonDown("RAP"))
- {
- }
- if (Input.GetButtonUp("RAP"))
- {
- }
- // Button: Back
- if (Input.GetButton("Back"))
- {
- }
- if (Input.GetButtonDown("Back"))
- {
- }
- if (Input.GetButtonUp("Back"))
- {
- }
- // Button: Start
- if (Input.GetButton("Start"))
- {
- }
- if (Input.GetButtonDown("Start"))
- {
- }
- if (Input.GetButtonUp("Start"))
- {
- }
- }
- // Button Constructor
- void pushButton(){
- for(int i=0; i < xBox360.Length; i++)
- {
- if (xBox360[i].ButtonName == "A")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "B")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "X")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "Y")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "LB")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "RB")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "Start")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- if (xBox360[i].ButtonName == "Back")
- {
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Down)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Hold)
- {
- }
- if (xBox360[i].ButtonAction == Buttons.ButtonType.Up)
- {
- }
- }
- }
- }
- // Helpers
- public static float floatToDegree(float v, float h)
- {
- return Mathf.Atan2(v, h) * 180 / Mathf.PI;
- }
- public static int getDegreeCircle(float winkel, int n)
- {
- if (winkel < 0) winkel += 360;
- float verschiebung = 360 / (float)(2 * n);
- for (int i = 0; i < n; i++)
- {
- float start_winkel = 360 * i / (float)n;
- float end_winkel = 360 * (i + 1) / (float)n;
- //Verschiebung
- start_winkel -= verschiebung;
- end_winkel -= verschiebung;
- if (start_winkel < 0) start_winkel += 360;
- if (end_winkel < 0) end_winkel += 360;
- if (winkel < end_winkel && winkel >= start_winkel)
- return i;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement