Initialer Upload neues Unity-Projekt

This commit is contained in:
Daniel Ocks
2025-07-21 09:11:14 +02:00
commit eeca72985b
14558 changed files with 1508140 additions and 0 deletions

View File

@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AppDeeplinkUI : MonoBehaviour
{
// these are just for illustration, you'll need to modify them to match your own app ids
const ulong UNITY_COMPANION_APP_ID = 3535750239844224;
const ulong UNREAL_COMPANION_APP_ID = 4055411724486843;
RectTransform deeplinkAppId;
RectTransform deeplinkMessage;
RectTransform uiLaunchType;
RectTransform uiLaunchSource;
RectTransform uiDeepLinkMessage;
bool inMenu = true;
// Start is called before the first frame update
void Start()
{
DebugUIBuilder ui = DebugUIBuilder.instance;
uiLaunchType = ui.AddLabel("UnityDeeplinkSample");
ui.AddDivider();
ui.AddButton("launch OtherApp", LaunchOtherApp);
ui.AddButton("launch UnrealDeeplinkSample", LaunchUnrealDeeplinkSample);
deeplinkAppId = CustomDebugUI.instance.AddTextField(UNITY_COMPANION_APP_ID.ToString(), 0);
deeplinkMessage = CustomDebugUI.instance.AddTextField("MSG_UNITY_SAMPLE", 0);
ui.AddButton("LaunchSelf", LaunchSelf);
if (Application.platform == RuntimePlatform.Android)
{
// init ovr platform
if (!Oculus.Platform.Core.IsInitialized())
{
Oculus.Platform.Core.Initialize();
}
}
uiLaunchType = ui.AddLabel("LaunchType: ");
uiLaunchSource = ui.AddLabel("LaunchSource: ");
uiDeepLinkMessage = ui.AddLabel("DeeplinkMessage: ");
ui.ToggleLaserPointer(true);
ui.Show();
}
// Update is called once per frame
void Update()
{
DebugUIBuilder ui = DebugUIBuilder.instance;
if (Application.platform == RuntimePlatform.Android)
{
// retrieve + update launch details
Oculus.Platform.Models.LaunchDetails
launchDetails = Oculus.Platform.ApplicationLifecycle.GetLaunchDetails();
uiLaunchType.GetComponentInChildren<Text>().text = "LaunchType: " + launchDetails.LaunchType;
uiLaunchSource.GetComponentInChildren<Text>().text = "LaunchSource: " + launchDetails.LaunchSource;
uiDeepLinkMessage.GetComponentInChildren<Text>().text = "DeeplinkMessage: " + launchDetails.DeeplinkMessage;
}
if (OVRInput.GetDown(OVRInput.Button.Two) || OVRInput.GetDown(OVRInput.Button.Start))
{
if (inMenu)
{
DebugUIBuilder.instance.Hide();
}
else
{
DebugUIBuilder.instance.Show();
}
inMenu = !inMenu;
}
}
void LaunchUnrealDeeplinkSample()
{
Debug.Log(string.Format("LaunchOtherApp({0})", UNREAL_COMPANION_APP_ID));
var options = new Oculus.Platform.ApplicationOptions();
options.SetDeeplinkMessage(deeplinkMessage.GetComponentInChildren<Text>().text);
Oculus.Platform.Application.LaunchOtherApp(UNREAL_COMPANION_APP_ID, options);
}
void LaunchSelf()
{
// launch self, assumes android platform
ulong appId;
if (ulong.TryParse(Oculus.Platform.PlatformSettings.MobileAppID, out appId))
{
Debug.Log(string.Format("LaunchSelf({0})", appId));
var options = new Oculus.Platform.ApplicationOptions();
options.SetDeeplinkMessage(deeplinkMessage.GetComponentInChildren<Text>().text);
Oculus.Platform.Application.LaunchOtherApp(appId, options);
}
}
void LaunchOtherApp()
{
ulong appId;
if (ulong.TryParse(deeplinkAppId.GetComponentInChildren<Text>().text, out appId))
{
Debug.Log(string.Format("LaunchOtherApp({0})", appId));
var options = new Oculus.Platform.ApplicationOptions();
options.SetDeeplinkMessage(deeplinkMessage.GetComponentInChildren<Text>().text);
Oculus.Platform.Application.LaunchOtherApp(appId, options);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 027619fb17fc6bc45ae5b76ade2abc42
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6364657505b0dec47a9c599164dd6cbf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CustomDebugUI : MonoBehaviour
{
[SerializeField]
private RectTransform textPrefab = null;
public static CustomDebugUI instance;
const System.Reflection.BindingFlags privateFlags =
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
void Awake()
{
Debug.Assert(instance == null);
instance = this;
}
public RectTransform AddTextField(string label, int targetCanvas = 0)
{
RectTransform textRT = GameObject.Instantiate(textPrefab).GetComponent<RectTransform>();
InputField inputField = textRT.GetComponentInChildren<InputField>();
inputField.text = label;
DebugUIBuilder ui = DebugUIBuilder.instance;
var addRect = typeof(DebugUIBuilder).GetMethod("AddRect", privateFlags);
addRect.Invoke(ui, new object[] { textRT, targetCanvas });
return textRT;
}
public void RemoveFromCanvas(RectTransform element, int targetCanvas = 0)
{
DebugUIBuilder ui = DebugUIBuilder.instance;
var field = typeof(DebugUIBuilder).GetField("insertedElements", privateFlags);
var relayout = typeof(DebugUIBuilder).GetMethod("Relayout", privateFlags);
List<RectTransform>[] elements = (List<RectTransform>[])field.GetValue(ui);
if (targetCanvas > -1 && targetCanvas < elements.Length - 1)
{
elements[targetCanvas].Remove(element);
element.SetParent(null);
relayout.Invoke(ui, new object[] { });
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f58ede4971e20144484e6aec209350be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ad318b8a60c4f774cbbf0d9e4d4fcca9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: