コード例 #1
0
    protected override void OnGUI()
    {
        base.OnGUI();

        smartCheckError(smartARController);

        if (smartARController.smart_.isConstructorFailed())
        {
            return;
        }

        if (GUI.Button(new Rect(0, Screen.height - 100, 200, 100), "Reset"))
        {
            smartARController.resetController();
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        if (smartARController.enabled_)
        {
            GUI.Label(new Rect(0, 0, 1000, 1000), labelText_);
            smartARController.getAndroidCameraFeature(out apiLevel_, out hwFeature_, out canChangeNewAPI_);
            updateLabelText(apiLevel_, hwFeature_, canChangeNewAPI_);

            if (GUI.Button(new Rect(Screen.width - 200, Screen.height - 100, 200, 100), "API:1<->2"))
            {
                success_ = smartARController.changeAndroidCameraAPI(out apiLevel_, out hwFeature_, out canChangeNewAPI_);
                updateLabelText(apiLevel_, hwFeature_, canChangeNewAPI_);
            }
        }
#endif
    }
コード例 #2
0
    protected override void OnGUI()
    {
        base.OnGUI();

        smartCheckError(smartARController);

        if (smartARController.smart_.isConstructorFailed())
        {
            return;
        }

        // Do action
        if (_DoSaveSceneMap)
        {
            var fileStreamOut = new smartar.FileStreamOut(smartARController.smart_, _SceneMapFilePath);
            smartARController.saveSceneMap(fileStreamOut);
            fileStreamOut.Close();
            fileStreamOut   = null;
            _DoSaveSceneMap = false;
            return;
        }
        else if (_DoLoadSceneMap)
        {
            smartARController.loadSceneMap(_SceneMapFilePath);
            _IsFix            = true;
            _IsSceneMapLoaded = true;
            _DoLoadSceneMap   = false;
            return;
        }
        else if (_DoReset)
        {
            smartARController.resetController();
            _DoReset = false;
            return;
        }
        else if (_DoClearMap)
        {
            smartARController.reCreateController(smartARController.orgRecognizerSettings_.recognitionMode, smartARController.orgRecognizerSettings_.sceneMappingInitMode);
            _IsSceneMapLoaded = false;
            _DoClearMap       = false;
            return;
        }
        else if (_DoSwitchFixSceneMap)
        {
            _IsFix = !_IsFix;
            smartARController.recognizer_.FixSceneMap(_IsFix);
            _DoSwitchFixSceneMap = false;
            return;
        }

#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        mySkin.button.fontSize = 15;
        mySkin.label.fontSize  = 15;
#endif

        var buttonLongSide   = Math.Max((float)Screen.width * 0.1f, (float)Screen.height * 0.1f);
        var buttonNarrowSide = Math.Min((float)Screen.width * 0.1f, (float)Screen.height * 0.1f);

        if (GUI.Button(new Rect(0, Screen.height - buttonNarrowSide, buttonLongSide, buttonNarrowSide), "Reset"))
        {
            _DoReset = true;
        }

        var width  = buttonLongSide * 5 / 2;
        var height = buttonNarrowSide;

        if (_IsSceneMapLoaded)
        {
            if (GUI.Button(new Rect(Screen.width - width, Screen.height - height, width, height), "Clear scene map"))
            {
                _DoClearMap = true;
            }
        }

        if (GUI.Button(new Rect(Screen.width - width, 0, width, height), "SaveSceneMap"))
        {
            _DoSaveSceneMap = true;
        }

        if (GUI.Button(new Rect(Screen.width - width, height, width, height), "LoadSceneMap"))
        {
            _DoLoadSceneMap = true;
        }

        if (GUI.Button(new Rect(Screen.width - width, height * 2, width, height), (_IsFix ? "FixSceneMap to Off" : "FixSceneMap to On")))
        {
            _DoSwitchFixSceneMap = true;
        }
    }