add random color for tuio visualizer

master
tigerchen 6 years ago
parent caa00b6aac
commit 966b72a031
  1. 6
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab
  2. 14
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity
  3. 11
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs

@ -32,10 +32,10 @@ RectTransform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {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} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8998964087612649377 --- !u!222 &8998964087612649377
CanvasRenderer: CanvasRenderer:

@ -228,8 +228,8 @@ RectTransform:
- {fileID: 1329477503} - {fileID: 1329477503}
- {fileID: 503604496} - {fileID: 503604496}
- {fileID: 229700560} - {fileID: 229700560}
- {fileID: 728173365}
- {fileID: 1191269362} - {fileID: 1191269362}
- {fileID: 728173365}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -702,13 +702,13 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 385543094} m_Father: {fileID: 385543094}
m_RootOrder: 3 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0, y: 0}
--- !u!225 &728173366 --- !u!225 &728173366
CanvasGroup: CanvasGroup:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -897,7 +897,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 385543094} m_Father: {fileID: 385543094}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}

@ -1,10 +1,10 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class touchVisualizer : MonoBehaviour public class touchVisualizer : MonoBehaviour
{ {
public RectTransform debug_canvas; public RectTransform debug_canvas;
public RectTransform _rect; public RectTransform _rect;
@ -25,17 +25,20 @@ public class touchVisualizer : MonoBehaviour
if (debug_touches.ContainsKey(id) == false) if (debug_touches.ContainsKey(id) == false)
{ {
GameObject t = Instantiate(_rect.gameObject, debug_canvas); 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<RawImage>().color = new Color(r, g, b);
t.name = "debug" + id.ToString(); t.name = "debug" + id.ToString();
tran = t.GetComponent<RectTransform>(); tran = t.GetComponent<RectTransform>();
debug_touches.Add(id, tran); debug_touches.Add(id, tran);
var rt = tran.transform as RectTransform; tran.anchoredPosition = touches[id].position;
rt.anchoredPosition = touches[id].position;
//tran.position = touches[id].position; //tran.position = touches[id].position;
} }
else else
{ {
tran = debug_touches[id]; tran = debug_touches[id];
tran.position = touches[id].position; tran.anchoredPosition = touches[id].position;
} }
} }

Loading…
Cancel
Save