Esempio n. 1
0
    //Read RawData from each json files in vibDataFiles array and add those data to vibDictionary
    private void ReadVibDataFromJson()
    {
        TextAsset[] _vibDataFiles = Resources.LoadAll <TextAsset>("VibData");

        for (int _i = 0; _i < _vibDataFiles.Length; _i++)
        {
            VibDataContent vibDataContent = JsonUtility.FromJson <VibDataContent>(_vibDataFiles[_i].ToString()); //parse json
            string[]       strigns        = vibDataContent.RawData.Split(',');
            byte[]         _bytes         = new byte[strigns.Length];                                            //convert rawdata to byte array

            for (int i = 0; i < strigns.Length; i++)
            {
                _bytes[i] = System.Convert.ToByte(int.Parse(strigns[i]));
            }

            OVRHapticsClip _clip = new OVRHapticsClip(_bytes, _bytes.Length);

            string _name = _vibDataFiles[_i].name;
            // Replace non alphabetic characters to underscore
            _name = _name = Regex.Replace(_name, @"[^a-zA-Z0-9가-힣]", "_");
            // Remove space in enums
            _name = _name.Replace(" ", string.Empty);

            VibKey _key = (VibKey)System.Enum.Parse(typeof(VibKey), _name);
            vibDictionary.Add(_key, _clip);               //add these data sets to dictionary
        }
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();

        //select and check enumerized keys
        selectedKey        = (VibKey)EditorGUILayout.EnumPopup("VibKey", selectedKey);
        VibManager.testKey = selectedKey;

        if (GUILayout.Button("Test"))
        {
            TestVibration();
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.HelpBox("Test works on runtime only", MessageType.Warning);
        EditorGUILayout.HelpBox("Usage : OVRHaptics.LeftChannel.Mix(VibManager.vibDictionary[Vibkey.VibSample1]);", MessageType.Info);

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        //reset keys in enum by reading json files in VibData folder
        if (GUILayout.Button("Refresh Vibkey"))
        {
            EnumerizeKeys();
        }
    }
Esempio n. 3
0
    private void Update()
    {
        //index trigger down
        if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger))
        {
            Debug.Log("IndexTrigger down");

            VibKey key = VibKey.VibSample1;
            switch (index)
            {
            case 0: key = VibKey.VibSample1; break;

            case 1: key = VibKey.VibSample2; break;

            case 2: key = VibKey.VibSample3; break;
            }

            index++;
            if (index == 3)
            {
                index = 0;
            }

            OVRHaptics.LeftChannel.Mix(VibManager.vibDictionary[key]);
        }
    }
Esempio n. 4
0
    //Read RawData from each json files in vibDataFiles array and add those data to vibDictionary
    private void ReadVibDataFromJson()
    {
        TextAsset[] vibDataFiles = Resources.LoadAll <TextAsset>("VibData");

        vibDictionary = new Dictionary <VibKey, OVRHapticsClip>();

        for (int _i = 0; _i < vibDataFiles.Length; _i++)
        {
            VibDataContent vibDataContent = JsonUtility.FromJson <VibDataContent>(vibDataFiles[_i].ToString()); //parse json
            byte[]         _bytes         = StringToByte(vibDataContent.RawData);                               //convert rawdata to byte array
            OVRHapticsClip _clip          = new OVRHapticsClip(_bytes, _bytes.Length);
            VibKey         _key           = (VibKey)System.Enum.Parse(typeof(VibKey), vibDataFiles[_i].name);
            vibDictionary.Add(_key, _clip);               //add these data sets to dictionary
        }
    }
Esempio n. 5
0
    private void ReadVibDataFromAudioClips()
    {
        AudioClip[] _audioClips = Resources.LoadAll <AudioClip>("VibData");

        for (int _i = 0; _i < _audioClips.Length; _i++)
        {
            OVRHapticsClip _clip = new OVRHapticsClip(_audioClips[_i]);

            string _name = _audioClips[_i].name;
            // Replace non alphabetic characters to underscore
            _name = _name = Regex.Replace(_name, @"[^a-zA-Z0-9가-힣]", "_");
            // Remove space in enums
            _name = _name.Replace(" ", string.Empty);

            VibKey _key = (VibKey)System.Enum.Parse(typeof(VibKey), _name);
            vibDictionary.Add(_key, _clip);               //add these audio base clips to dictionary
        }
    }
Esempio n. 6
0
    private void Update()
    {
        //index trigger down
        if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger))
        {
            Debug.Log("IndexTrigger down");

            VibKey key = (VibKey)index;

            index++;
            if (index == 3)
            {
                index = 0;
            }

            OVRHaptics.LeftChannel.Mix(VibManager.vibDictionary[key]);
        }
    }