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 new file mode 100644 index 0000000..da2f46d --- /dev/null +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab @@ -0,0 +1,72 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4561369756670910991 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2843357119042037495} + - component: {fileID: 8998964087612649377} + - component: {fileID: 3911409587028272619} + m_Layer: 5 + m_Name: TUIO_Debug + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2843357119042037495 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4561369756670910991} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + 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_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 200, y: 200} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8998964087612649377 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4561369756670910991} + m_CullTransparentMesh: 0 +--- !u!114 &3911409587028272619 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4561369756670910991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0.9176218, b: 0, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Texture: {fileID: 10912, guid: 0000000000000000f000000000000000, type: 0} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab.meta b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab.meta new file mode 100644 index 0000000..638f4e1 --- /dev/null +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Prefabs/TUIO_Debug.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e138d516c2f8921419701ebaace6d191 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: 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 91027a3..4904e16 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,7 +228,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &503604495 GameObject: @@ -341,7 +341,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} propertyPath: m_RootOrder - value: 7 + value: 8 objectReference: {fileID: 0} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -486,6 +486,117 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &655193970 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 655193971} + - component: {fileID: 655193974} + - component: {fileID: 655193973} + - component: {fileID: 655193972} + - component: {fileID: 655193975} + m_Layer: 5 + m_Name: Debug_Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &655193971 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655193970} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &655193972 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655193970} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &655193973 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655193970} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &655193974 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655193970} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 3 + m_TargetDisplay: 0 +--- !u!225 &655193975 +CanvasGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655193970} + m_Enabled: 1 + m_Alpha: 1 + m_Interactable: 1 + m_BlocksRaycasts: 1 + m_IgnoreParentGroups: 0 --- !u!1 &798465529 GameObject: m_ObjectHideFlags: 0 @@ -578,9 +689,8 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - {fileID: 503604496} - - {fileID: 1959362813} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -609,6 +719,7 @@ GameObject: m_Component: - component: {fileID: 914806965} - component: {fileID: 914806966} + - component: {fileID: 914806967} m_Layer: 0 m_Name: TUIO_Event m_TagString: Untagged @@ -628,7 +739,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &914806966 MonoBehaviour: @@ -644,10 +755,25 @@ MonoBehaviour: m_EditorClassIdentifier: img: {fileID: 2829506254029656376, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3} canvas: {fileID: 798465533} + VisualizeTouches: 1 frame_gap: 20 delta_threshold: 100 img_fade_speed: 0.02 img_wait_sec: 2 +--- !u!114 &914806967 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 914806964} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ca88ef87f2450a340a79ce723372f2db, type: 3} + m_Name: + m_EditorClassIdentifier: + debug_canvas: {fileID: 655193971} + _rect: {fileID: 2843357119042037495, guid: e138d516c2f8921419701ebaace6d191, type: 3} --- !u!1 &963194225 GameObject: m_ObjectHideFlags: 0 @@ -913,7 +1039,7 @@ Canvas: m_SortingBucketNormalizedSize: 0 m_AdditionalShaderChannelsFlag: 0 m_SortingLayerID: 0 - m_SortingOrder: 3 + m_SortingOrder: 2 m_TargetDisplay: 0 --- !u!224 &1781519748 RectTransform: @@ -928,97 +1054,10 @@ RectTransform: m_Children: - {fileID: 229700560} m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} ---- !u!1 &1959362812 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1959362813} - - component: {fileID: 1959362816} - - component: {fileID: 1959362815} - - component: {fileID: 1959362814} - m_Layer: 5 - m_Name: TUIO_Debug - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &1959362813 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1959362812} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 798465533} - m_RootOrder: 1 - 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_AnchoredPosition: {x: 0, y: -600} - m_SizeDelta: {x: 2527, y: 1200} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1959362814 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1959362812} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 62f7dec0b00674947bc631624c21970a, type: 3} - m_Name: - m_EditorClassIdentifier: - _nameFilter: Spout DX11 Sender - _targetTexture: {fileID: 8400000, guid: e567e88d5f268114c873ccbdd25b0557, type: 2} - _targetRenderer: {fileID: 0} - _targetMaterialProperty: _MainTex ---- !u!114 &1959362815 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1959362812} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: -98529514, guid: f70555f144d8491a825f0804e09c671c, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Texture: {fileID: 8400000, guid: e567e88d5f268114c873ccbdd25b0557, type: 2} - m_UVRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 ---- !u!222 &1959362816 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1959362812} - m_CullTransparentMesh: 0 diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs index 66619e8..4c1a27e 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs @@ -43,7 +43,6 @@ public class movieController : MonoBehaviour alpha = 1; stat = 2; } - } else if (stat == 2 && force_destroy) { 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 new file mode 100644 index 0000000..76e5fc8 --- /dev/null +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs @@ -0,0 +1,56 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class touchVisualizer : MonoBehaviour +{ + + public Transform debug_canvas; + public RectTransform _rect; + + Dictionary debug_touches = new Dictionary(); + + // Update is called once per frame + void Update() + { + if (GetComponent().VisualizeTouches) + debug_canvas.GetComponent().alpha = 1f; + else + debug_canvas.GetComponent().alpha = 0f; + + var touches = TUIOManager.Instance.touches; + foreach (var id in touches.Keys) + { + RectTransform tran = null; + if (debug_touches.ContainsKey(id) == false) + { + GameObject t = Instantiate(_rect.gameObject, debug_canvas); + t.name = "debug" + id.ToString(); + tran = t.GetComponent(); + debug_touches.Add(id, tran); + tran.position = touches[id].position; + } + else + { + tran = debug_touches[id]; + tran.position = touches[id].position; + } + } + + var removes = new HashSet(); + foreach (var id in debug_touches.Keys) + { + if (touches.ContainsKey(id) == false) // remove + { + removes.Add(id); + } + } + + foreach (var id in removes) + { + debug_touches.Remove(id); + Destroy(GameObject.Find("debug" + id.ToString())); + } + } +} + diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs.meta b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs.meta new file mode 100644 index 0000000..abcf7ca --- /dev/null +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/touchVisualizer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca88ef87f2450a340a79ce723372f2db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs index 775cf68..0e82605 100644 --- a/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs +++ b/08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs @@ -7,9 +7,13 @@ public class tuio_event : MonoBehaviour { public movieController img; public Transform canvas; + Dictionary movies = new Dictionary(); Dictionary pre_pos = new Dictionary(); + [Config] + public bool VisualizeTouches = true; + [Config] [Range(1, 30)] public int frame_gap = 20; @@ -28,9 +32,12 @@ public class tuio_event : MonoBehaviour void Update() { + GetComponent().enabled = VisualizeTouches; + var touches = TUIOManager.Instance.touches; foreach (var id in touches.Keys) { + movieController movie = null; if (movies.ContainsKey(id) == false) // Add { @@ -48,6 +55,7 @@ public class tuio_event : MonoBehaviour else //update { movie = movies[id]; + if (Time.frameCount % frame_gap == 0) { float delta_pos = Vector2.Distance(pre_pos[id], movie.transform.position);