-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple 2D viewing mode when no headset is present (#421)
* Initial stab at allowing a simple 2D viewing mode when no headset is present [CI BUILD] * UX improvements and some help text. Don't invert look by default * Slow default speed and allow shift for sprinting * dotnet-format * Nit... * Touchscreen controls for mobile non-VR * Add a close button to view mode * dotnet-format
- Loading branch information
Showing
12 changed files
with
4,009 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using UnityEngine.EventSystems; | ||
using UnityEngine.UI; | ||
|
||
namespace TiltBrush | ||
{ | ||
[RequireComponent(typeof(Button))] | ||
public class TouchscreenVirtualKey : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler | ||
{ | ||
public char m_Key; | ||
[NonSerialized] public bool m_IsPressed; | ||
|
||
private Button _button; | ||
|
||
private void Awake() | ||
{ | ||
_button = GetComponent<Button>(); | ||
} | ||
|
||
public void OnPointerDown(PointerEventData eventData) | ||
{ | ||
if (!_button.interactable) return; | ||
m_IsPressed = true; | ||
} | ||
|
||
public void OnPointerUp(PointerEventData eventData) | ||
{ | ||
m_IsPressed = false; | ||
} | ||
|
||
public void OnPointerExit(PointerEventData eventData) | ||
{ | ||
m_IsPressed = false; | ||
} | ||
|
||
// Afaik needed so Pointer exit works .. doing nothing further | ||
public void OnPointerEnter(PointerEventData eventData) { } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using TiltBrush; | ||
using UnityEngine; | ||
|
||
public class ViewModeUI : MonoBehaviour | ||
{ | ||
public GameObject m_UiRoot; | ||
|
||
void Awake() | ||
{ | ||
m_UiRoot.SetActive(!App.VrSdk.IsHmdInitialized()); | ||
} | ||
|
||
public void HandleCloseButton() | ||
{ | ||
// TODO If we allow other tools than the FlyTool, we should probably have | ||
// a better way to test if the load sketch dialog is showing | ||
if (SketchSurfacePanel.m_Instance.ActiveToolType == BaseTool.ToolType.FlyTool) | ||
{ | ||
// We're viewing a sketch so close it and open the loading dialog | ||
ApiMethods.NewSketch(); | ||
SketchSurfacePanel.m_Instance.DisableSpecificTool(BaseTool.ToolType.FlyTool); | ||
App.Instance.CreateFailedToDetectVrDialog(); | ||
} | ||
else | ||
{ | ||
// We're hopefully showing the sketch loading dialog so close the app | ||
Application.Quit(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2023 The Open Brush Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using TMPro; | ||
using UnityEngine; | ||
|
||
namespace TiltBrush | ||
{ | ||
public class InitNoHeadsetMode : MonoBehaviour | ||
{ | ||
|
||
public GameObject m_SketchLoadingUi; | ||
|
||
void Start() | ||
{ | ||
var dropdown = GetComponentInChildren<TMP_Dropdown>(); | ||
dropdown.ClearOptions(); | ||
var userSketchSet = SketchCatalog.m_Instance.GetSet(SketchSetType.User); | ||
for (int i = 0; i < userSketchSet.NumSketches; i++) | ||
{ | ||
var sketchName = userSketchSet.GetSketchName(i); | ||
dropdown.options.Add(new TMP_Dropdown.OptionData(sketchName)); | ||
} | ||
var curatedSketchSet = SketchCatalog.m_Instance.GetSet(SketchSetType.Curated); | ||
for (int i = 0; i < curatedSketchSet.NumSketches; i++) | ||
{ | ||
var sketchName = curatedSketchSet.GetSketchName(i); | ||
dropdown.options.Add(new TMP_Dropdown.OptionData(sketchName)); | ||
} | ||
} | ||
|
||
public void Init() | ||
{ | ||
var cameraPos = App.VrSdk.GetVrCamera().transform.position; | ||
cameraPos.y += 12; | ||
App.VrSdk.GetVrCamera().transform.position = cameraPos; | ||
var dropdown = GetComponentInChildren<TMP_Dropdown>(); | ||
var index = dropdown.value; | ||
|
||
var sketchSet = SketchCatalog.m_Instance.GetSet(SketchSetType.User); | ||
if (index < sketchSet.NumSketches) | ||
{ | ||
SceneFileInfo rInfo = sketchSet.GetSketchSceneFileInfo(index); | ||
if (rInfo != null) | ||
{ | ||
SketchControlsScript.m_Instance.LoadSketch(rInfo, true); | ||
} | ||
} | ||
else | ||
{ | ||
index -= sketchSet.NumSketches; | ||
sketchSet = SketchCatalog.m_Instance.GetSet(SketchSetType.Curated); | ||
var rInfo = sketchSet.GetSketchSceneFileInfo(index); | ||
if (rInfo != null) | ||
{ | ||
SketchControlsScript.m_Instance.LoadSketch(rInfo, true); | ||
} | ||
} | ||
|
||
SketchSurfacePanel.m_Instance.EnableSpecificTool(BaseTool.ToolType.FlyTool); | ||
Destroy(gameObject); | ||
} | ||
|
||
public void ShowSketchSelectorUi(bool active = true) | ||
{ | ||
m_SketchLoadingUi.SetActive(active); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.