Initialer Upload neues Unity-Projekt
This commit is contained in:
@ -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[] { });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f58ede4971e20144484e6aec209350be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Oculus/SampleFramework/Usage/AppDeeplink/UI/DebugTextField.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/Oculus/SampleFramework/Usage/AppDeeplink/UI/DebugTextField.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad318b8a60c4f774cbbf0d9e4d4fcca9
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user