Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        blueToothPlugin = BlueToothPlugin.GetInstance();
        blueToothPlugin.SetDebug(0);
        blueToothPlugin.Init();

        blueToothPlugin.SetConnectionCallbackListener(
            OnConnected
            , OnConnecting
            , OnNotConnected
            , OnConnectionFailed
            , OnConnectionLost
            , OnConnectToDevice
            );

        blueToothPlugin.SetDataCallbackListener(OnRecievedMessage, OnSentMessage, OnLogMessage);

        bool isEnable = blueToothPlugin.CheckBlueTooth();

        Debug.Log("[BlueToothDemo] isBlueToothEnable: " + isEnable);

        if (!isEnable)
        {
            blueToothPlugin.EnsureDiscoverable();
        }
        else
        {
            blueToothPlugin.InitServer();
        }
    }
    /*private Action <string>RecievedData;
    public event Action <string>OnRecievedData{
        add{RecievedData+=value;}
        remove{RecievedData-=value;}
    }

    private Action <string>SentData;
    public event Action <string>OnSentData{
        add{SentData+=value;}
        remove{SentData-=value;}
    }

    private Action <string>LogMessage;
    public event Action <string>OnLogMessage{
        add{LogMessage+=value;}
        remove{LogMessage-=value;}
    }*/
    public static BlueToothPlugin GetInstance()
    {
        if(instance==null){
            container = new GameObject();
            container.name="BlueToothPlugin";
            instance = container.AddComponent( typeof(BlueToothPlugin) ) as BlueToothPlugin;
            DontDestroyOnLoad(instance.gameObject);
        }

        return instance;
    }
Esempio n. 3
0
    public static BlueToothPlugin GetInstance()
    {
        if(instance==null){
            aupHolder = AUPHolder.GetInstance();
            container = new GameObject();
            container.name="BlueToothPlugin";
            instance = container.AddComponent( typeof(BlueToothPlugin) ) as BlueToothPlugin;
            DontDestroyOnLoad(instance.gameObject);
            instance.gameObject.transform.SetParent(aupHolder.gameObject.transform);
        }

        return instance;
    }
Esempio n. 4
0
    public static BlueToothPlugin GetInstance()
    {
        if (instance == null)
        {
            aupHolder      = AUPHolder.GetInstance();
            container      = new GameObject();
            container.name = "BlueToothPlugin";
            instance       = container.AddComponent(typeof(BlueToothPlugin)) as BlueToothPlugin;
            DontDestroyOnLoad(instance.gameObject);
            instance.gameObject.transform.SetParent(aupHolder.gameObject.transform);
        }

        return(instance);
    }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        blueToothPlugin = BlueToothPlugin.GetInstance();
        blueToothPlugin.SetDebug(0);
        blueToothPlugin.Init();

        blueToothPlugin.SetConnectionCallbackListener(
            OnConnected
            ,OnConnecting
            ,OnNotConnected
            ,OnConnectionFailed
            ,OnConnectionLost
            ,OnConnectToDevice
            );

        blueToothPlugin.SetDataCallbackListener(OnRecievedMessage,OnSentMessage,OnLogMessage);

        bool isEnable = blueToothPlugin.CheckBlueTooth();
        Debug.Log("[BlueToothDemo] isBlueToothEnable: " + isEnable);

        if(!isEnable){
            blueToothPlugin.EnsureDiscoverable();
        }else{
            blueToothPlugin.InitServer();
        }
    }