Fix Max Coding v?, make VR-Able
This commit is contained in:
3
vr-configurator/.gitignore
vendored
3
vr-configurator/.gitignore
vendored
@@ -77,3 +77,6 @@ crashlytics-build.properties
|
||||
# These things dont seem to be intended to be here
|
||||
.vsconfig
|
||||
TempAssembly.dll
|
||||
|
||||
# Max eternal git struggle
|
||||
export.json
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 05d394ae2a81edd4cbc3c51917e766e3, type: 3}
|
||||
m_Name: OculusProjectConfig
|
||||
m_EditorClassIdentifier:
|
||||
targetDeviceTypes: 0100000002000000030000000400000005000000
|
||||
targetDeviceTypes: 02000000030000000400000005000000
|
||||
allowOptional3DofHeadTracking: 0
|
||||
handTrackingSupport: 1
|
||||
handTrackingFrequency: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,15 @@
|
||||
using TMPro;
|
||||
using Unity.XR.CoreUtils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class BaseModelSelector : MonoBehaviour
|
||||
{
|
||||
private Canvas _canvas;
|
||||
private GameObject _buttonPrefab;
|
||||
private Button[] _modelButtons;
|
||||
public Canvas canvas;
|
||||
public GameObject buttonPrefab;
|
||||
public PortSelector portSelector;
|
||||
|
||||
|
||||
public ModelManager modelManager; // <-- to be put in inspector
|
||||
public ModelManager modelManager;
|
||||
|
||||
public GameObject unexplodeButton;
|
||||
public GameObject ContentUi;
|
||||
@@ -20,80 +18,29 @@ public class BaseModelSelector : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
buttonPrefab.SetActive(false);
|
||||
_canvasButtons.SetActive(false);
|
||||
SetupEventSystem();
|
||||
SetupCanvas();
|
||||
CreatePrefabButtons();
|
||||
|
||||
CreateModelButtons();
|
||||
}
|
||||
|
||||
void SetupEventSystem()
|
||||
void CreateModelButtons()
|
||||
{
|
||||
if (FindFirstObjectByType<EventSystem>() == null)
|
||||
float startY = 0f; // Start position on Y axis
|
||||
float buttonHeight = 0.3f; // Distance between Buttons
|
||||
foreach (var model in ModelList.BaseModels)
|
||||
{
|
||||
GameObject eventSystemGo = new GameObject("EventSystem");
|
||||
eventSystemGo.AddComponent<EventSystem>();
|
||||
//eventSystemGo.AddComponent<UnityEngine.InputSystem.UI.InputSystemUIInputModule>(); //Put in for keyboard input. Must be commented out on quest
|
||||
eventSystemGo.AddComponent<OVRInputModule>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("EventSystem already exists - new one will not be created.");
|
||||
}
|
||||
}
|
||||
var button = Spawn.GO(buttonPrefab, canvas.transform, new Vector3(0, startY, 0), "ModelButton:" + model.NameId);
|
||||
button.GetNamedChild("Icon").GetComponent<Image>().sprite = Resources.Load<Sprite>($"sprites/" + model.NameId);
|
||||
button.GetNamedChild("ModelName").GetComponent<TextMeshProUGUI>().text = model.NameHuman;
|
||||
button.GetComponent<Button>().onClick.AddListener(() => OnModelButtonClicked(model));
|
||||
button.SetActive(true);
|
||||
|
||||
void SetupCanvas()
|
||||
{
|
||||
GameObject canvasGo = new GameObject("ModelSelectorCanvas");
|
||||
canvasGo.transform.SetParent(gameObject.transform);
|
||||
_canvas = canvasGo.AddComponent<Canvas>();
|
||||
_canvas.renderMode = RenderMode.WorldSpace;
|
||||
|
||||
var cameraRig = GameObject.Find("[BuildingBlock] Camera Rig");
|
||||
if (cameraRig != null)
|
||||
{
|
||||
var centerEye = cameraRig.transform.Find("TrackingSpace/CenterEyeAnchor");
|
||||
_canvas.worldCamera = centerEye.GetComponent<Camera>();
|
||||
_canvas.transform.position = centerEye.position + centerEye.forward * 2f;
|
||||
_canvas.transform.rotation = Quaternion.LookRotation(_canvas.transform.position - centerEye.position);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Camera Rig not found!");
|
||||
}
|
||||
|
||||
canvasGo.AddComponent<CanvasScaler>().uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
canvasGo.AddComponent<GraphicRaycaster>();
|
||||
canvasGo.AddComponent<OVRRaycaster>();
|
||||
}
|
||||
|
||||
|
||||
void CreatePrefabButtons()
|
||||
{
|
||||
float startY = 0.8f; // Start position on Y axis
|
||||
float buttonHeight = 0.5f; // Distance between Buttons
|
||||
foreach (var baseModel in ModelList.BaseModels)
|
||||
{
|
||||
GameObject buttonGo = SetupPrefab(baseModel);
|
||||
buttonGo.transform.SetParent(_canvas.transform);
|
||||
RectTransform rt = buttonGo.GetComponent<RectTransform>();
|
||||
var collider = buttonGo.AddComponent<BoxCollider>();
|
||||
rt.sizeDelta = new Vector2(300, 50);
|
||||
buttonGo.transform.localScale = Vector3.one * 0.005f;// Buttons size
|
||||
buttonGo.transform.localPosition = new Vector3(0, startY, 0); // Position in the Canvas
|
||||
buttonGo.transform.localRotation = Quaternion.identity;
|
||||
|
||||
// Setup Collider correctly
|
||||
collider.size = new Vector3(rt.sizeDelta.x * rt.localScale.x, rt.sizeDelta.y * rt.localScale.y, 1f);
|
||||
collider.center = Vector3.zero;
|
||||
|
||||
buttonGo.GetComponent<Button>().onClick.AddListener(() => OnModelButtonClicked(baseModel));
|
||||
startY -= buttonHeight; // Next button below
|
||||
}
|
||||
|
||||
}
|
||||
// When button is clicked
|
||||
public void OnModelButtonClicked(BaseModel model)
|
||||
|
||||
void OnModelButtonClicked(BaseModel model)
|
||||
{
|
||||
Debug.Log($"Selected model: {model.NameHuman}");
|
||||
|
||||
@@ -118,7 +65,7 @@ public class BaseModelSelector : MonoBehaviour
|
||||
}
|
||||
_canvasButtons.SetActive(true);
|
||||
|
||||
if (_canvas == null)
|
||||
if (canvas == null)
|
||||
{
|
||||
Debug.LogError("Canvas doesn't exist");
|
||||
return;
|
||||
@@ -131,6 +78,7 @@ public class BaseModelSelector : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
ContentUi.SetActive(true);
|
||||
|
||||
if (unexplodeButton == null)
|
||||
{
|
||||
Debug.LogError("UnexplodeButton is null!");
|
||||
@@ -138,57 +86,6 @@ public class BaseModelSelector : MonoBehaviour
|
||||
unexplodeButton.SetActive(false);
|
||||
}
|
||||
|
||||
public static GameObject SetupPrefab(BaseModel model)
|
||||
{
|
||||
// Main object
|
||||
GameObject buttonGo = new GameObject("ModelButton_" + model.NameId);
|
||||
buttonGo.AddComponent<RectTransform>();
|
||||
|
||||
buttonGo.AddComponent<Button>();
|
||||
|
||||
var image = buttonGo.AddComponent<Image>();
|
||||
|
||||
// Load background from Resources/UI/ButtonBackgrounds/
|
||||
var backgroundSprite = Resources.Load<Sprite>($"sprites/default");
|
||||
if (backgroundSprite != null)
|
||||
image.sprite = backgroundSprite;
|
||||
else
|
||||
image.color = new Color(0.2f, 0.2f, 0.2f, 0.8f); // Fallback-Color
|
||||
|
||||
// Size
|
||||
RectTransform rt = buttonGo.GetComponent<RectTransform>();
|
||||
rt.sizeDelta = new Vector2(300, 100);
|
||||
|
||||
// === Icon ===
|
||||
GameObject iconGo = new GameObject("Icon");
|
||||
iconGo.transform.SetParent(buttonGo.transform, false);
|
||||
var iconImage = iconGo.AddComponent<Image>();
|
||||
iconImage.sprite = Resources.Load<Sprite>($"sprites/"+model.NameId);
|
||||
|
||||
RectTransform iconRT = iconGo.GetComponent<RectTransform>();
|
||||
iconRT.anchorMin = new Vector2(0, 0.5f);
|
||||
iconRT.anchorMax = new Vector2(0, 0.5f);
|
||||
iconRT.pivot = new Vector2(0, 0.5f);
|
||||
iconRT.anchoredPosition = new Vector2(10, 0);
|
||||
iconRT.sizeDelta = new Vector2(44, 22);
|
||||
|
||||
// === Title ===
|
||||
GameObject titleGo = new GameObject("TitleText");
|
||||
titleGo.transform.SetParent(buttonGo.transform, false);
|
||||
var titleText = titleGo.AddComponent<TextMeshProUGUI>();
|
||||
titleText.text = model.NameHuman;
|
||||
titleText.fontSize = 24;
|
||||
|
||||
RectTransform titleRT = titleGo.GetComponent<RectTransform>();
|
||||
titleRT.anchorMin = new Vector2(0, 1);
|
||||
titleRT.anchorMax = new Vector2(1, 1);
|
||||
titleRT.pivot = new Vector2(0, 1);
|
||||
titleRT.anchoredPosition = new Vector2(60, -10);
|
||||
titleRT.sizeDelta = new Vector2(-70, 30);
|
||||
|
||||
return buttonGo;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
@@ -860,7 +860,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2b7365b139f7aec43b23d26b7a48b5a6, type: 3}
|
||||
m_Name: MetaQuestTouchPlusControllerProfile Standalone
|
||||
m_EditorClassIdentifier:
|
||||
m_enabled: 0
|
||||
m_enabled: 1
|
||||
nameUi: Meta Quest Touch Plus Controller Profile
|
||||
version: 0.0.1
|
||||
featureIdInternal: com.unity.openxr.feature.input.metaquestplus
|
||||
@@ -1047,7 +1047,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: feeef8d85de8db242bdda70cc7ff5acd, type: 3}
|
||||
m_Name: OculusTouchControllerProfile Android
|
||||
m_EditorClassIdentifier:
|
||||
m_enabled: 0
|
||||
m_enabled: 1
|
||||
nameUi: Oculus Touch Controller Profile
|
||||
version: 0.0.1
|
||||
featureIdInternal: com.unity.openxr.feature.input.oculustouch
|
||||
|
||||
@@ -12,12 +12,12 @@ PlayerSettings:
|
||||
targetDevice: 2
|
||||
useOnDemandResources: 0
|
||||
accelerometerFrequency: 60
|
||||
companyName: DefaultCompany
|
||||
productName: vr-configurator
|
||||
companyName: HTW Saarland
|
||||
productName: VR Konfigurator
|
||||
defaultCursor: {fileID: 0}
|
||||
cursorHotspot: {x: 0, y: 0}
|
||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||
m_ShowUnitySplashScreen: 1
|
||||
m_ShowUnitySplashScreen: 0
|
||||
m_ShowUnitySplashLogo: 1
|
||||
m_SplashScreenOverlayOpacity: 1
|
||||
m_SplashScreenAnimation: 1
|
||||
@@ -257,7 +257,7 @@ PlayerSettings:
|
||||
clonedFromGUID: 3c72c65a16f0acb438eed22b8b16c24a
|
||||
templatePackageId: com.unity.template.urp-blank@17.0.11
|
||||
templateDefaultScene: Assets/Scenes/SampleScene.unity
|
||||
useCustomMainManifest: 0
|
||||
useCustomMainManifest: 1
|
||||
useCustomLauncherManifest: 0
|
||||
useCustomMainGradleTemplate: 0
|
||||
useCustomLauncherGradleManifest: 0
|
||||
@@ -829,6 +829,7 @@ PlayerSettings:
|
||||
platformArchitecture: {}
|
||||
scriptingBackend:
|
||||
Android: 1
|
||||
Standalone: 0
|
||||
il2cppCompilerConfiguration: {}
|
||||
il2cppCodeGeneration: {}
|
||||
il2cppStacktraceInformation: {}
|
||||
@@ -921,7 +922,7 @@ PlayerSettings:
|
||||
qnxGraphicConfPath:
|
||||
apiCompatibilityLevel: 6
|
||||
captureStartupLogs: {}
|
||||
activeInputHandler: 2
|
||||
activeInputHandler: 1
|
||||
windowsGamepadBackendHint: 0
|
||||
cloudProjectId: 1d5ce6cf-bb74-453c-8977-54bbbbfe519c
|
||||
framebufferDepthMemorylessMode: 0
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"baseModel": true,"modelId": "erlbach", "ports": [{ "i": 74, "modelId": "idErlbachPart74", "portId": "portErlbach74"},{ "i": 75, "modelId": "idErlbachPart75", "portId": "portErlbach75"},{ "i": 76, "modelId": "idErlbachPart76", "portId": "batteriePack"},{ "i": 80, "modelId": "idErlbachWheel_LH", "portId": "wheel"},{ "i": 81, "modelId": "idErlbachWheel_LV", "portId": "wheel"},{ "i": 82, "modelId": "idErlbachWheel_RH", "portId": "wheel"},{ "i": 83, "modelId": "idErlbachWheel_RV", "portId": "wheel"},{ "i": 84, "modelId": "idErlbachPart84", "portId": "body"},{ "i": 85, "modelId": "idErlbachPart85", "portId": "portErlbach85"},{ "i": 86, "modelId": "idErlbachPart86", "portId": "portErlbach86"},{ "i": 87, "modelId": "idErlbachPart87", "portId": "portErlbach87"},{ "i": 88, "modelId": "idErlbachPart88", "portId": "portErlbach88"},{ "i": 89, "modelId": "idErlbachPart89", "portId": "portErlbach89"},{ "i": 90, "modelId": "idErlbachPart90", "portId": "portErlbach90"},{ "i": 91, "modelId": "idErlbachPart91", "portId": "portErlbach91"},{ "i": 92, "modelId": "idErlbachPart92", "portId": "portErlbach92"},{ "i": 93, "modelId": "idErlbachPart93", "portId": "portErlbach93"}]}
|
||||
Reference in New Issue
Block a user