From 966b72a031c1f7b7e70a8e992a3369fbb217896c Mon Sep 17 00:00:00 2001 From: tigerchen Date: Fri, 13 Dec 2019 19:26:26 +0800 Subject: [PATCH] add random color for tuio visualizer --- .../Assets/Prefabs/TUIO_Debug.prefab | 6 +++--- .../19050-08-DarkSea/Assets/Scenes/DarkSea.unity | 14 +++++++------- .../Assets/Scripts/touchVisualizer.cs | 11 +++++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab index da2f46d..ce13a31 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab @@ -32,10 +32,10 @@ RectTransform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 200, y: 200} + m_SizeDelta: {x: 256, y: 256} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &8998964087612649377 CanvasRenderer: diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity index b3e8ab0..1186082 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity @@ -228,8 +228,8 @@ RectTransform: - {fileID: 1329477503} - {fileID: 503604496} - {fileID: 229700560} - - {fileID: 728173365} - {fileID: 1191269362} + - {fileID: 728173365} m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -702,13 +702,13 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 385543094} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!225 &728173366 CanvasGroup: m_ObjectHideFlags: 0 @@ -897,7 +897,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 385543094} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs index 58849bf..77cc967 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs @@ -1,10 +1,10 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; public class touchVisualizer : MonoBehaviour { - public RectTransform debug_canvas; public RectTransform _rect; @@ -25,17 +25,20 @@ public class touchVisualizer : MonoBehaviour if (debug_touches.ContainsKey(id) == false) { GameObject t = Instantiate(_rect.gameObject, debug_canvas); + float r = Random.Range(0.5f, 1f); + float g = Random.Range(0.5f, 1f); + float b = Random.Range(0.5f, 1f); + t.GetComponent().color = new Color(r, g, b); t.name = "debug" + id.ToString(); tran = t.GetComponent(); debug_touches.Add(id, tran); - var rt = tran.transform as RectTransform; - rt.anchoredPosition = touches[id].position; + tran.anchoredPosition = touches[id].position; //tran.position = touches[id].position; } else { tran = debug_touches[id]; - tran.position = touches[id].position; + tran.anchoredPosition = touches[id].position; } }