Removed TOTU 103

This commit is contained in:
Ignacio Gómez Puga
2025-03-04 12:04:52 -06:00
commit 5847d844a5
675 changed files with 76582 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
// Copyright 2022-2024 Niantic.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationToggle : MonoBehaviour
{
public bool Open;
[SerializeField]
private Animator m_Animator;
public void toggleStateFunction()
{
if (Open)
{
m_Animator.SetTrigger("Close");
}
else
{
m_Animator.SetTrigger("Open");
}
Open = !Open;
}
public void CloseState()
{
if (Open)
{
m_Animator.SetTrigger("Close");
Open = !Open;
}
}
public void OpenState()
{
if (!Open)
{
m_Animator.SetTrigger("Open");
Open = !Open;
}
}
}

View File

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

View File

@@ -0,0 +1,162 @@
// Copyright 2022-2024 Niantic.
using System.Text;
using UnityEngine.XR.ARFoundation;
using UnityEngine.UI;
using UnityEngine;
namespace Niantic.Lightship.AR.Samples
{
public abstract class DisplayImage : MonoBehaviour
{
// Name of the display rotation matrix in the shader.
const string k_DisplayMatrixName = "_DisplayMatrix";
private readonly int k_DisplayMatrix = Shader.PropertyToID(k_DisplayMatrixName);
protected readonly StringBuilder m_StringBuilder = new();
protected ScreenOrientation m_CurrentScreenOrientation;
[SerializeField]
[Tooltip("The ARCameraManager which will produce camera frame events.")]
ARCameraManager m_CameraManager;
[SerializeField]
[Tooltip("Raw Image UI element for display.")]
protected RawImage m_RawImage;
[SerializeField]
[Tooltip("Material using the shader.")]
Material m_Material;
[SerializeField]
[Tooltip("UI Text field for image info")]
Text m_ImageInfo;
private Camera m_camera;
protected virtual void Awake()
{
// Acquire a reference to the rendering camera
m_camera = m_CameraManager.GetComponent<Camera>();
// Get the current screen orientation, and update the raw image UI
m_CurrentScreenOrientation = Screen.orientation;
}
protected virtual void OnEnable()
{
UpdateRawImage();
}
protected virtual void Update()
{
Debug.Assert(m_RawImage != null, "no raw image");
// If the raw image needs to be updated because of a device orientation change or because of a texture
// aspect ratio difference, then update the raw image with the new values.
if (m_CurrentScreenOrientation != Screen.orientation)
{
m_CurrentScreenOrientation = Screen.orientation;
UpdateRawImage();
}
// Update the image
var sizeDelta = m_RawImage.rectTransform.sizeDelta;
OnUpdatePresentation(
viewportWidth: (int)sizeDelta.x,
viewportHeight: (int)sizeDelta.y,
orientation: m_CurrentScreenOrientation,
renderingMaterial: m_RawImage.material,
image: out var texture,
displayMatrix: out var displayMatrix);
m_RawImage.texture = texture;
m_RawImage.material.SetMatrix(k_DisplayMatrix, displayMatrix);
if (m_RawImage.texture != null)
{
// Display some text information about each of the textures.
var displayTexture = m_RawImage.texture as Texture2D;
if (displayTexture != null)
{
m_StringBuilder.Clear();
BuildTextureInfo(m_StringBuilder, "env", displayTexture);
LogText(m_StringBuilder.ToString());
}
}
}
/// <summary>
/// Invoked when it is time to update the presentation.
/// </summary>
/// <param name="viewportWidth">The width of the portion of the screen the image will be rendered onto.</param>
/// <param name="viewportHeight">The height of the portion of the screen the image will be rendered onto.</param>
/// <param name="orientation">The orientation of the screen.</param>
/// <param name="renderingMaterial">The material used to render the image.</param>
/// <param name="image">The image to render.</param>
/// <param name="displayMatrix">A transformation matrix to fit the image onto the viewport.</param>
protected abstract void OnUpdatePresentation( int viewportWidth, int viewportHeight, ScreenOrientation orientation,
Material renderingMaterial, out Texture image, out Matrix4x4 displayMatrix);
private static void BuildTextureInfo(StringBuilder stringBuilder, string textureName, Texture2D texture)
{
stringBuilder.AppendLine($"texture : {textureName}");
if (texture == null)
{
stringBuilder.AppendLine(" <null>");
}
else
{
stringBuilder.AppendLine($" format : {texture.format}");
stringBuilder.AppendLine($" width : {texture.width}");
stringBuilder.AppendLine($" height : {texture.height}");
stringBuilder.AppendLine($" mipmap : {texture.mipmapCount}");
}
}
private void LogText(string text)
{
if (m_ImageInfo != null)
{
m_ImageInfo.text = text;
}
else
{
Debug.Log(text);
}
}
private void UpdateRawImage()
{
Debug.Assert(m_RawImage != null, "no raw image");
// The aspect ratio of the presentation in landscape orientation
var aspect = Mathf.Max(m_camera.pixelWidth, m_camera.pixelHeight) /
(float)Mathf.Min(m_camera.pixelWidth, m_camera.pixelHeight);
// Determine the raw image rectSize preserving the texture aspect ratio, matching the screen orientation,
// and keeping a minimum dimension size.
float minDimension = 480.0f;
float maxDimension = Mathf.Round(minDimension * aspect);
Vector2 rectSize;
switch (m_CurrentScreenOrientation)
{
case ScreenOrientation.LandscapeRight:
case ScreenOrientation.LandscapeLeft:
rectSize = new Vector2(maxDimension, minDimension);
break;
case ScreenOrientation.PortraitUpsideDown:
case ScreenOrientation.Portrait:
default:
rectSize = new Vector2(minDimension, maxDimension);
break;
}
// Update the raw image dimensions and the raw image material parameters.
m_RawImage.rectTransform.sizeDelta = rectSize;
m_RawImage.material = m_Material;
}
}
}

View File

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

View File

@@ -0,0 +1,22 @@
// Copyright 2022-2024 Niantic.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FillHelpText : MonoBehaviour
{
[SerializeField] TextAsset textFile;
[SerializeField] Text uiTextBox;
// Scene info text to text box.
void Start()
{
if(textFile != null)
uiTextBox.text = textFile.text;
}
public void moveToBottom(){
Vector2 pos = gameObject.transform.parent.GetComponent<RectTransform>().anchoredPosition;
gameObject.transform.parent.GetComponent<RectTransform>().anchoredPosition = new Vector2(pos.x,1332);
}
}

View File

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

View File

@@ -0,0 +1,94 @@
// Copyright 2022-2024 Niantic.
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace Niantic.ARDKExamples.Helpers
{
// Simple scrolling window that prints to the application screen whatever is printed through
// calls to the UnityEngine.Debug.Log method.
[DefaultExecutionOrder(Int32.MinValue)]
public class ScrollingLog:
MonoBehaviour
{
/// Font size for log text entries. Spacing between log entries is also set to half this value.
[SerializeField]
private int LogEntryFontSize = 32;
/// The maximum number of log entries to keep history of
[SerializeField][Range(1, 100)]
private int MaxLogCount = 100;
/// Layout box containing the log entries
[SerializeField]
private VerticalLayoutGroup LogHistory = null;
/// Log entry prefab used to generate new entries when requested
[SerializeField]
private Text LogEntryPrefab = null;
private readonly List<Text> _logEntries = new List<Text>();
private static ScrollingLog _instance;
private void Awake()
{
_instance = this;
LogHistory.spacing = LogEntryFontSize / 2f;
}
private void OnEnable()
{
// Using logMessageReceived (instead of logMessageReceivedThreaded) to ensure that
// HandleDebugLog is only called from one thread (the main thread).
Application.logMessageReceived += AddLogEntry;
}
private void OnDisable()
{
Application.logMessageReceived -= AddLogEntry;
}
private void OnDestroy()
{
_instance = null;
}
// Creates a new log entry using the provided string.
private void AddLogEntry(string str, string stackTrace, LogType type)
{
var newLogEntry = Instantiate(LogEntryPrefab, Vector3.zero, Quaternion.identity);
newLogEntry.text = str;
newLogEntry.fontSize = LogEntryFontSize;
newLogEntry.color = Color.white;
var transform = newLogEntry.transform;
transform.SetParent(LogHistory.transform);
transform.localScale = Vector3.one;
_logEntries.Add(newLogEntry);
if (_logEntries.Count > MaxLogCount)
{
var textObj = _logEntries.First();
_logEntries.RemoveAt(0);
Destroy(textObj.gameObject);
}
}
public static void Clear()
{
if (_instance == null)
return;
foreach (var entry in _instance._logEntries)
Destroy(entry.gameObject);
_instance._logEntries.Clear();
}
}
}

View File

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

View File

@@ -0,0 +1,37 @@
// Copyright 2022-2024 Niantic.
using System;
using UnityEngine;
using UnityEngine.UI;
public class SliderToggle : Toggle
{
[SerializeField] private RectTransform uiHandleRectTransform;
private Vector2 _handlePosition;
protected override void Awake()
{
_handlePosition = uiHandleRectTransform.anchoredPosition;
onValueChanged.AddListener(OnSwitch);
if (isOn)
{
OnSwitch(true);
}
base.Awake();
}
private void OnSwitch(bool on)
{
var Xvalue = on ? Math.Abs(_handlePosition.x) : Math.Abs(_handlePosition.x) * -1;
_handlePosition = new Vector2(Xvalue, _handlePosition.y);
uiHandleRectTransform.anchoredPosition = _handlePosition;
}
protected override void OnDestroy()
{
onValueChanged.RemoveListener(OnSwitch);
base.OnDestroy();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ee8f998d2c5a4f818357c1903e195bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 6a154d82dd47d42c2ba80feeee9d2582, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
// Copyright 2022-2024 Niantic.
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class SwipeController : MonoBehaviour, IEndDragHandler
{
[SerializeField]
private int _maxPage =2;
int _currentPage;
Vector3 _targetPos;
float _dragThreshold;
[SerializeField]
Vector3 _pageStep;
[SerializeField]
RectTransform _levelPagesRect;
[SerializeField]
float _lerpTime;
[SerializeField]
Image[] _slideImage;
[SerializeField]
Sprite _open;
[SerializeField]
Sprite _close;
// Start is called before the first frame update
void Awake()
{
_currentPage = 1;
_targetPos = _levelPagesRect.localPosition;
_dragThreshold = Screen.width * 0.01f;
UpdateSlider();
}
public void Next(){
if(_currentPage < _maxPage){
_currentPage++;
_targetPos += _pageStep;
StartCoroutine(MovePage());
}else{
StartCoroutine(MovePage());
}
}
public void Previous(){
if(_currentPage > 1){
_currentPage--;
_targetPos -= _pageStep;
StartCoroutine(MovePage());
}else{
StartCoroutine(MovePage());
}
}
IEnumerator MovePage(){
var t = 0f;
var Start = _levelPagesRect.localPosition;
while(t < 1){
t += Time.deltaTime / _lerpTime;
if(t > 1)
t = 1;
_levelPagesRect.localPosition = Vector3.Lerp(Start, _targetPos, t);
yield return null;
}
}
public void OnEndDrag(PointerEventData eventData)
{
if(Mathf.Abs(eventData.delta.x) > _dragThreshold){
if(eventData.delta.x > 0){
Previous();
}else{
Next();
}
}else{
MovePage();
}
UpdateSlider();
}
void UpdateSlider(){
foreach(var image in _slideImage){
image.color = new Color(0,0,0,0.5f);
}
_slideImage[_currentPage-1].color = new Color(0,0,0,1);
}
}

View File

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

View File

@@ -0,0 +1,28 @@
// Copyright 2022-2024 Niantic.
using UnityEngine;
using UnityEngine.UI;
public class VersionRead : MonoBehaviour
{
[SerializeField]
private Text uiTextBox;
private const string SamplesVersion = "3.10.0";
void Awake()
{
Screen.orientation = ScreenOrientation.Portrait;
}
// Start is called before the first frame update
void Start()
{
//uiTextBox.text = "ARDK: " + Niantic.Lightship.AR.Settings.Metadata.Version +
// "\n" + "Shared AR: " + Niantic.Lightship.SharedAR.Settings.Metadata.SharedArVersion +
// "\n" + "Samples: " + SamplesVersion;
}
}

View File

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