Search Unity

Make a Dictionary of OVRinputs.

Discussion in 'Scripting' started by KenClemson, Nov 5, 2016.

  1. KenClemson

    KenClemson

    Joined:
    Oct 6, 2016
    Posts:
    24
    Hi I cant cant seem to get my inputs to work and I'm not sure Iff Im doing this right.
    I can get "KeyCode" to work with my code but I cant seem to make "OVRinput.Button" work. I can get KeyCode to work like :
    Code (CSharp):
    1. private static Dictionary<string, KeyCode> KeyCodeStrings = new Dictionary<string, KeyCode>()
    2. {
    3. {"MoveLeft", KeyCode.a},
    4. {"MoveRight", KeyCode.d}
    5. };
    So Im trying to use the same thing but with OVRInput.Button as follows
    Code (CSharp):
    1. private static Dictionary<string, OVRInput.Button> OculusKeyStrings = new Dictionary<string, OVRInput.Button>()
    2. {
    3.        {"MoveLeft", OVRInput.Button.dpadLeft},
    4.        {"MoveRight", OVRInput.Button.dpadright}
    5. };
    Could anyone clarify iff OVRInput.Button would work in this context ?
     
  2. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    How are you trying to use this dictionary. I'm trying to imagine how a dictionary might be useful in handling input. especially if the Inputs are all in the value section and not the key part of the dictionary?
     
  3. KenClemson

    KenClemson

    Joined:
    Oct 6, 2016
    Posts:
    24
    They get written to a text file "inputs.txt" kind of like a config file so you can change your inputs to differnet actions in the game or vice versa
     
  4. KenClemson

    KenClemson

    Joined:
    Oct 6, 2016
    Posts:
    24
    I can post the rest of the code iff you like ?
     
  5. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    Ah I understand now, your using them to allow configurable controls. I don't see why that wouldn't work to do something like this:
    Code (CSharp):
    1. void Update()
    2. {
    3.         If (OVRInput.GetDown(OculusKeyStrings["MoveLeft"]))
    4.         {
    5.                  // Do Move Left code
    6.          }
    7. }
     
  6. KenClemson

    KenClemson

    Joined:
    Oct 6, 2016
    Posts:
    24
    Great ! thanks takatok, by applying your code it proved to me that my code should in theory work, because I placed the script on an object and I could get movement. So the reason I cant get my inputs working from the input.txt is from some other reason.