public void PutainDeButton()
    {
        //Clear the old options of the Dropdown menu
        m_db_toUpdate.ClearOptions();
        string sText = ForceTubeVRInterface.ListConnectedForceTube();

        //ChannelList channe
        //ChannelList channe
        if (sText != null)
        {
            ConnectedForceTube FTList = JsonUtility.FromJson <ConnectedForceTube>(sText);

            m_DropOptions = new List <string>();

            foreach (string sName in FTList.Connected)
            {
                m_DropOptions.Add(sName);
            }


            //Add the options created in the List above
            m_db_toUpdate.AddOptions(m_DropOptions);
            m_db_toUpdate.value = -1;
            m_db_toUpdate.RefreshShownValue();
        }
    }
    public void ScanChannel()
    {
        string sText = ForceTubeVRInterface.ListChannels();

        Debug.Log("ListChannels " + sText);

        DebugScan.text = sText;
    }
    public void ScanConnected()
    {
        string sText = ForceTubeVRInterface.ListConnectedForceTube();

        Debug.Log("ListConnectedForceTube " + sText);

        DebugScan.text = sText;
    }
    public void SaveJSONChannelTest()
    {
        string sText = ForceTubeVRInterface.ListChannels();

        string path     = Application.persistentDataPath;
        string filePath = path + "/ForceChannel.json";

        Debug.Log("filePath : " + filePath);
        File.WriteAllText(filePath, sText);
    }
    public void SaveJSONChannel()
    {
        /*string sText = ForceTubeVRInterface.ListChannels();
         *
         * string path = Application.persistentDataPath;
         * string filePath = path + "/ForceChannel.json";
         * Debug.Log("filePath : " + filePath);
         * File.WriteAllText(filePath,sText);*/

        ForceTubeVRInterface.SaveChannelJSon();
    }
    public void InitChannelsTest()
    {
        string path     = Application.persistentDataPath;
        string filePath = path + "/ForceChannel.json";

        Debug.Log("filePath : " + filePath);
        string dataAsJson = File.ReadAllText(filePath);

        bool bRet = ForceTubeVRInterface.InitChannels(dataAsJson);

        Debug.Log("ListConnectedForceTube " + bRet);
    }
    //public ListForceTube ListFT;



    void Awake()
    {
        Debug.Log("InitAsync");
        ForceTubeVRInterface.InitAsync(false);

        //string path = Application.persistentDataPath;
        //string filePath = path+"/ForceChannel.json";
        //string dataAsJson = File.ReadAllText(filePath);
        //bool bRet = ForceTubeVRInterface.InitChannels(dataAsJson);

        ForceTubeVRInterface.LoadChannelJSon();
    }
    public void LoadJSONChannel()
    {
        /*string path = Application.persistentDataPath;
         * string filePath = path + "/ForceChannel.json";
         * Debug.Log("filePath : " + filePath);
         * string dataAsJson = File.ReadAllText(filePath);
         *
         * bool bRet = ForceTubeVRInterface.InitChannels(dataAsJson);
         * Debug.Log("ListConnectedForceTube " + bRet);*/



        ForceTubeVRInterface.LoadChannelJSon();
    }
Exemple #9
0
    public static bool LoadChannelJSon()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (ForceTubeVRPlugin != null)
        {
            return(ForceTubeVRPlugin.Call <bool>("LoadChannelJSon"));
        }
        else
        {
            return(false);
        }
#else
        string path     = Application.persistentDataPath;
        string filePath = path + "/Channels.json";
        Debug.Log("filePath : " + filePath);
        string dataAsJson = File.ReadAllText(filePath);
        return(ForceTubeVRInterface.InitChannels(dataAsJson));
#endif
    }
Exemple #10
0
    public static bool SaveChannelJSon()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (ForceTubeVRPlugin != null)
        {
            return(ForceTubeVRPlugin.Call <bool>("SaveChannelJSon"));
        }
        else
        {
            return(false);
        }
#else
        string sText    = ForceTubeVRInterface.ListChannels();
        string path     = Application.persistentDataPath;
        string filePath = path + "/Channels.json";
        Debug.Log("filePath : " + filePath);
        File.WriteAllText(filePath, sText);
        return(true);
#endif
    }
 void Update()
 {
     if (auto)
     {
         autoTimer += Time.deltaTime;
         if (autoTimer >= autoDelay)
         {
             autoTimer -= autoDelay;
             ForceTubeVRInterface.Shoot(255, 255, 0.5f, target);
         }
     }
     if (ForceTubeVRInterface.GetBatteryLevel() == 255)
     {
         batteryText.text = "BatteryLevel : Not found.";
     }
     else
     {
         batteryText.text = "BatteryLevel : " + ForceTubeVRInterface.GetBatteryLevel().ToString() + "%";
     }
 }
    //[DllImport("ForceTubeVR_API_x64", EntryPoint = "GetDevices")]
    //private static extern List<List<ForceTubeVRDevice*>*>*  GetDevices_x64();

    //[DllImport("ForceTubeVR_API_x32", EntryPoint = "GetDevices")]
    //private static extern void GetDevices_x32();
#endif

    ///<summary>
    ///As suggered, this method is asynchronous.
    ///Only need to be called once to let the Dll manage the ForceTubeVR's connection.
    ///By default, InitAsync() place the first ForceTubeVR detected in the channel "rifleButt" and the second in "rifleBolt".
    ///If it receives a boolean true as first param, the first forcetubevr is placed in "pistol1" and the second in "pistol2".
    ///</summary>
    public static void InitAsync(bool pistolsFirst = false)
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (instance == null)
        {
            instance = (new GameObject("ForceTubeVRInterface")).AddComponent <ForceTubeVRInterface>();
            DontDestroyOnLoad(instance);
        }
        instance.StartCoroutine(InitAndroid(pistolsFirst));
#endif

#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_WSA)
        if (pistolsFirst)
        {
            if (IntPtr.Size == 8)
            {
                InitPistol_x64();
            }
            else
            {
                InitPistol_x32();
            }
        }
        else
        {
            if (IntPtr.Size == 8)
            {
                InitRifle_x64();
            }
            else
            {
                InitRifle_x32();
            }
        }
#endif
    }
 public void Rumble()
 {
     Debug.Log("Rumble");
     ForceTubeVRInterface.Rumble(255, 0.5f, target);
 }
    private ForceTubeVRChannel target;     //The example scene will send requests to this channel. The simplest is "all" (sending to all, ignoring the channel) and the channel rifle send requests to both "rifleButt" and "rifleBolt".


    void Awake()
    {
        Debug.Log("InitAsync");
        ForceTubeVRInterface.InitAsync(false);
    }
    public void RemoveFromChannel()
    {
        string sForceTube = this.sFT;//this.m_db_toUpdate.GetComponent<Dropdown>().itemText.text;

        ForceTubeVRInterface.RemoveFromChannel((int)this.ChannelToTest, sForceTube);
    }
 public void Shoot()
 {
     Debug.Log("Shoot");
     ForceTubeVRInterface.Shoot(255, 255, 0.5f, target);
 }
 public void DisconnectAll()
 {
     ForceTubeVRInterface.DisconnectAll();
 }
 public void OpenBluetoothSettings()
 {
     Debug.Log("Tyry open Bluetooth settings");
     ForceTubeVRInterface.OpenBluetoothSettings();
 }
 public void ClearChannel()
 {
     ForceTubeVRInterface.ClearChannel((int)this.ChannelToTest);
 }
 public void SetActiveResearch()
 {
     activeResearch = !activeResearch;
     Debug.Log("Set active research to " + activeResearch.ToString());
     ForceTubeVRInterface.SetActiveResearch(activeResearch);
 }
 public void Kick()
 {
     Debug.Log("Kick");
     ForceTubeVRInterface.Kick(255, target);
 }