public RoleScrollStruct(Transform parent, PackedSprite avatarSprite, PackedSprite roleSpriteBG, PackedSprite roleSpriteBG2, int panelIndex) { this.avatarSprite = avatarSprite; this.roleSpriteBG = roleSpriteBG; this.roleSpriteBG2 = roleSpriteBG2; //init the touch input _fingerTouch = new FingerTouch(this); _singleScroll = new SingleScrollPanel[] { // new SingleScrollPanel(parent,this,0,"role1100001000"), // new SingleScrollPanel(parent,this,1,"role1100002000"), // new SingleScrollPanel(parent,this,2,"role1100003000"), // new SingleScrollPanel(parent,this,3,"role1100004000"), // new SingleScrollPanel(parent,this,4,"role1100005000") new SingleScrollPanel(parent, this, 0, "BigAvatarMan1"), new SingleScrollPanel(parent, this, 1, "BigAvatarMan2"), new SingleScrollPanel(parent, this, 2, "BigAvatarMan3"), // new SingleScrollPanel(parent,this,3,"BigAvatarMan4"), // new SingleScrollPanel(parent,this,4,"BigAvatarMan5") }; RoleNameSelect = "BigAvatarMan" + (MaxRoleCnt * 0.5f + 1).ToString(); // RoleNameSelect = "BigAvatarMan3"; }
public void SaveTouch(Touch touch) { androidController.PlayTapSound(); GameObject circle = Instantiate(bubble); circle.GetComponent <SpriteRenderer>().color = CrossSceneInfos.mode == Mode.INDIVIDUAL ? colors[colorIndex] : colors[9]; NextColorIndex(); Vector3 fingerPos = touch.position; fingerPos.z = 5; circle.transform.position = Camera.main.ScreenToWorldPoint(fingerPos); FingerTouch ft = new FingerTouch { time = Time.time, touch = touch, circle = circle }; fingerTouches.Add(ft); }
void RecordPatterns() { // Eliminar del diccionario los toques marcados como finalizados List <int> itemsToRemove = new List <int>(); foreach (var pair in fingerTouches) { if (pair.Value.ended) { itemsToRemove.Add(pair.Key); } } foreach (int item in itemsToRemove) { fingerTouches.Remove(item); } #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 // Detectar toques, utilizado los eventos táctiles de Unity foreach (Touch touch in Input.touches) { if (fingerTouches.ContainsKey(touch.fingerId)) { /*if (Time.time - fingerTouches[touch.fingerId].startTime > maxDuration) * { * fingerTouches.Remove(touch.fingerId); * } * else*/ { FingerTouch fingerTouch = fingerTouches[touch.fingerId]; switch (touch.phase) { case TouchPhase.Ended: // Marcar toque como finalizado fingerTouch.ended = true; break; case TouchPhase.Canceled: fingerTouches.Remove(touch.fingerId); break; case TouchPhase.Moved: fingerTouches[touch.fingerId].MoveFinger(touch.position); break; case TouchPhase.Stationary: fingerTouches[touch.fingerId].MoveFinger(touch.position); break; } } } else if (touch.phase == TouchPhase.Began) { fingerTouches[touch.fingerId] = new FingerTouch(touch.fingerId, touch.position); } } #endif #if UNITY_STANDALONE || UNITY_EDITOR for (int touchID = 0; touchID < 3; touchID++) { // Si pulsamos el ratón por primera vez, se añade if (Input.GetMouseButtonDown(touchID)) { fingerTouches[touchID] = new FingerTouch(touchID, Input.mousePosition); } // Si levantamos el ratón, se marca para eliminar else if (Input.GetMouseButtonUp(touchID)) { fingerTouches[touchID].ended = true; } // Si estña pulsado pero no lo hemos pulsado por primera vez ni levantado else if (Input.GetMouseButton(touchID)) { fingerTouches[touchID].MoveFinger(Input.mousePosition); } } #endif }