fix update touch & add configuration params

master
tigerchen 6 years ago
parent 40a314611d
commit 6538d78eac
  1. 24
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scenes/DarkSea.unity
  2. 16
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/movieController.cs
  3. 71
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Assets/Scripts/tuio_event.cs
  4. 2
      08_DarkSea/Unity-19050-08-DarkSea/19050-08-DarkSea/Packages/manifest.json

@ -202,7 +202,7 @@ Transform:
m_LocalScale: {x: 2.585, y: 1, z: 1.2} m_LocalScale: {x: 2.585, y: 1, z: 1.2}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!1 &299496350 --- !u!1 &299496350
GameObject: GameObject:
@ -294,7 +294,7 @@ Transform:
m_LocalScale: {x: 2.585, y: 1, z: 1.2} m_LocalScale: {x: 2.585, y: 1, z: 1.2}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &503604495 --- !u!1 &503604495
GameObject: GameObject:
@ -407,7 +407,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 8 value: 7
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3} - target: {fileID: 4472652550524646, guid: 1f68bf7cec2600e49a46d2f0554453c8, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
@ -545,7 +545,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: 0} m_Father: {fileID: 0}
m_RootOrder: 5 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.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
@ -619,7 +619,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &797223803 --- !u!1 &797223803
GameObject: GameObject:
@ -785,7 +785,7 @@ RectTransform:
- {fileID: 797223804} - {fileID: 797223804}
- {fileID: 1959362813} - {fileID: 1959362813}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 6
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: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@ -821,7 +821,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &914806966 --- !u!114 &914806966
MonoBehaviour: MonoBehaviour:
@ -835,8 +835,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e7eda42473bde25468ccb55d2b565cf9, type: 3} m_Script: {fileID: 11500000, guid: e7eda42473bde25468ccb55d2b565cf9, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
img: {fileID: 2142686115215515793, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3} img: {fileID: 2829506254029656376, guid: 8bbc036a3be21954681613cbe4f0e9a8, type: 3}
canvas: {fileID: 798465533} canvas: {fileID: 798465533}
frame_gap: 20
delta_threshold: 100
img_fade_speed: 0.02
img_wait_sec: 2
--- !u!1 &963194225 --- !u!1 &963194225
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -918,7 +922,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &963194229 --- !u!114 &963194229
MonoBehaviour: MonoBehaviour:
@ -1005,7 +1009,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: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 5
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.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}

@ -9,18 +9,18 @@ public class movieController : MonoBehaviour
{ {
DShowMoviePlayer player; DShowMoviePlayer player;
public int id; public int id;
public float fade_speed = 0.02f;
public int stat; public int stat;
public float alpha; public float fade_speed;
public bool force_destroy;
public float destroy_timer; public float destroy_timer;
public bool CanDsetroy; public float wait_sec = 2f;
float wait_sec = 2f; float alpha;
void Awake() void Awake()
{ {
player = GetComponent<DShowMoviePlayer>(); player = GetComponent<DShowMoviePlayer>();
CanDsetroy = true;
stat = 1; stat = 1;
force_destroy = false;
} }
void Start() void Start()
@ -45,6 +45,10 @@ public class movieController : MonoBehaviour
} }
} }
else if (stat == 2 && force_destroy)
{
stat = 3;
}
else if (stat == 3) else if (stat == 3)
{ {
float t = Time.time; float t = Time.time;
@ -52,7 +56,7 @@ public class movieController : MonoBehaviour
{ {
//Debug.Log("fade"); //Debug.Log("fade");
alpha -= fade_speed; alpha -= fade_speed;
if (alpha < 0 && CanDsetroy) if (alpha < 0)
{ {
Destroy(this.gameObject); Destroy(this.gameObject);
} }

@ -1,16 +1,31 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UltraCombos.Configuration;
public class tuio_event : MonoBehaviour public class tuio_event : MonoBehaviour
{ {
#if true public movieController img;
public GameObject img;
public Transform canvas; public Transform canvas;
//public UltraCombos.GlobalMKHookInput tuio_input;
Dictionary<int, movieController> movies = new Dictionary<int, movieController>(); Dictionary<int, movieController> movies = new Dictionary<int, movieController>();
Dictionary<int, Vector2> pre_pos = new Dictionary<int, Vector2>(); Dictionary<int, Vector2> pre_pos = new Dictionary<int, Vector2>();
[Config]
[Range(1, 30)]
public int frame_gap = 20;
[Config]
[Range(50, 300)]
public int delta_threshold = 100;
[Config]
[Range(0.01f, 0.1f)]
public float img_fade_speed = 0.02f;
[Config]
[Range(0.01f, 5f)]
public float img_wait_sec = 2f;
void Update() void Update()
{ {
var touches = TUIOManager.Instance.touches; var touches = TUIOManager.Instance.touches;
@ -19,48 +34,32 @@ public class tuio_event : MonoBehaviour
movieController movie = null; movieController movie = null;
if (movies.ContainsKey(id) == false) // Add if (movies.ContainsKey(id) == false) // Add
{ {
Debug.Log("Add"); //Debug.Log("Add");
GameObject g = Instantiate(img, canvas); GameObject g = Instantiate(img.gameObject, canvas);
g.name = id.ToString(); g.name = id.ToString();
movie = g.AddComponent<movieController>(); movie = g.AddComponent<movieController>();
movie.fade_speed = img_fade_speed;
movie.wait_sec = img_wait_sec;
movie.id = id; movie.id = id;
movies.Add(id, movie); movies.Add(id, movie);
movie.transform.position = touches[id].position; movie.transform.position = touches[id].position;
pre_pos.Add(id, touches[id].position); pre_pos[id] = touches[id].position;
} }
else //update else //update
{ {
if (Time.frameCount % 10 == 0) movie = movies[id];
if (Time.frameCount % frame_gap == 0)
{ {
float delta_pos = Vector2.Distance(pre_pos[id], touches[id].position); float delta_pos = Vector2.Distance(pre_pos[id], movie.transform.position);
if (delta_pos > 200) //float delta_pos = 199;
{ //Debug.Log("delta pos = " + delta_pos);
Debug.Log("generate new one"); if (delta_pos > delta_threshold)
GameObject g = Instantiate(img, canvas);
int clone_id = id + Random.Range(5000, 10000);
g.name = clone_id.ToString();
movie = g.AddComponent<movieController>();
movie.id = clone_id;
movies.Add(clone_id, movie);
movie.transform.position = pre_pos[id];
movie.transform.localRotation = movies[id].transform.localRotation;
movie.alpha = 0.9f;
movies[id].stat = 0;
movies[id].transform.position = touches[id].position;
movies[id].CanDsetroy = false;
movies[id].rotateImg();
pre_pos[id] = touches[id].position;
}
else
{ {
//movies[id].transform.position = touches[id].position; movie.force_destroy = true;
movie.destroy_timer = Time.time;
movies.Remove(id);
} }
} pre_pos[id] = touches[id].position;
else
{
movie = movies[id];
} }
} }
//update or after adding //update or after adding
@ -83,12 +82,10 @@ public class tuio_event : MonoBehaviour
{ {
movies[id].stat = 3; movies[id].stat = 3;
movies[id].destroy_timer = Time.time; movies[id].destroy_timer = Time.time;
movies[id].CanDsetroy = true;
movies.Remove(id); movies.Remove(id);
Debug.Log("Remove"); //Debug.Log("Remove");
} }
//movies[id].destroy_timer = Time.time; //movies[id].destroy_timer = Time.time;
} }
} }
#endif
} }

@ -3,6 +3,8 @@
"com.ultracombos.movie-player": "file:<project>/../../../../../_Package/com.ultracombos.movie-player", "com.ultracombos.movie-player": "file:<project>/../../../../../_Package/com.ultracombos.movie-player",
"com.ultracombos.tuio": "file:<project>/../../../../../_Package/com.ultracombos.tuio", "com.ultracombos.tuio": "file:<project>/../../../../../_Package/com.ultracombos.tuio",
"com.ultracombos.osc": "file:<project>/../../../../../_Package/com.ultracombos.osc", "com.ultracombos.osc": "file:<project>/../../../../../_Package/com.ultracombos.osc",
"com.ultracombos.grpc": "file:<project>/../../../../../_Package/com.ultracombos.grpc",
"com.ultracombos.configuration": "file:<project>/../../../../../_Package/com.ultracombos.configuration",
"jp.keijiro.klak.spout": "file:<project>/../../../../../_Package/KlakSpout", "jp.keijiro.klak.spout": "file:<project>/../../../../../_Package/KlakSpout",
"com.unity.ads": "2.0.8", "com.unity.ads": "2.0.8",
"com.unity.analytics": "3.2.2", "com.unity.analytics": "3.2.2",

Loading…
Cancel
Save