public override void mUpdate() { base.mUpdate(); if (Input.GetMouseButtonDown(0) && uguiHitUI.uiHited == false) { canMove = false; Vector2 v2 = GetScreenToWorldPos(Input.mousePosition); colli = Physics2D.OverlapPoint(v2); if (colli == null) { setState(FreeState2D.NAME); return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { handle.SetState(selectMachine); return; } ObjView view = colli.GetComponent <ObjView>(); if (view == null) { setState(FreeState2D.NAME); return; } else if (view == viewTarget) { canMove = true; return; } else { changed = true; string stateName = view.GetState(); SelectState state = getSelectState(stateName); if (state == null) { return; } state.viewTarget = view; setState(stateName); } } if (Input.GetMouseButtonUp(0)) { canMove = false; } }
public override void mPhoneUpdate() { base.mPhoneUpdate(); if (uguiHitUI.uiHited == true || Input.touchCount != 1) { return; } Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { Vector2 v2 = GetScreenToWorldPos(touch.position); colli = Physics2D.OverlapPoint(v2); if (colli == null) { setState(FreeState2D.NAME); return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { return; } ObjView view = colli.GetComponent <ObjView>(); if (view == null) { return; } else if (view.objData == target) { return; } else { if (view.objData is ProductData) { Select(view.objData as ProductData); } } } }
public override void mUpdate() { base.mUpdate(); if (Input.GetMouseButtonDown(0) && uguiHitUI.uiHited == false) { Vector2 v2 = GetScreenToWorldPos(Input.mousePosition); colli = Physics2D.OverlapPoint(v2); if (colli == null) { setState(FreeState2D.NAME); return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { return; } ObjView view = colli.GetComponent <ObjView>(); if (view == null) { return; } else if (view.objData == target) { return; } else { if (view.objData is ProductData) { Select(view.objData as ProductData); } } } }
public override void mPhoneUpdate() { base.mPhoneUpdate(); if (uguiHitUI.uiHited == true || Input.touchCount != 1) { return; } Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { canMove = false; Vector2 v2 = GetScreenToWorldPos(touch.position); colli = Physics2D.OverlapPoint(v2); if (colli == null) { setState(FreeState2D.NAME); return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { handle.SetState(selectMachine); return; } ObjView view = colli.GetComponent <ObjView>(); if (view == null) { setState(FreeState2D.NAME); return; } else if (view == viewTarget) { canMove = true; return; } else { changed = true; tempColiiView = view; } } else if (touch.phase == TouchPhase.Moved) { tempColiiView = null; } else if (touch.phase == TouchPhase.Ended) { if (canMove == true) { canMove = false; return; } if (tempColiiView == null) { setState(FreeState2D.NAME); return; } string stateName = tempColiiView.GetState(); SelectState state = getSelectState(stateName); if (state == null) { return; } state.viewTarget = tempColiiView; setState(stateName); } }
public override void mPhoneUpdate() { base.mPhoneUpdate(); if (uguiHitUI.uiHited == true || Input.touchCount != 1) { return; } Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { onhandle = false; moved = false; canMove = false; colli = null; Ray ray = inputCamera.ScreenPointToRay(touch.position); //RaycastHit hit; //bool hited = Physics.Raycast(ray, out hit); //if (hited == false) //{ // colli = null; // return; //} //colli = hit.collider; int count = Physics.RaycastNonAlloc(ray, raycastArr); if (count > 0) { raycastList.Clear(); for (int i = 0; i < count; i++) { raycastList.Add(raycastArr[i]); } // raycastList.Sort( // delegate (RaycastHit hit1, RaycastHit hit2) // { // if (hit1.distance > hit2.distance) return 1; // else return -1; // } //); SortDis(raycastList); float rayhitdis = float.MaxValue; for (int i = 0; i < count; i++) { if (colli != null && raycastList[i].distance > raycastList[0].distance + 5) { break; } float dis; bool hit = raycastFunc.RaycastMesh(touch.position, raycastList[i].collider.gameObject, out dis); if (hit == true) { if (dis < rayhitdis) { colli = raycastList[i].collider; rayhitdis = dis; } } } if (colli == null) { colli = raycastList[0].collider; } } if (colli == null) { return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { handle.SetState(selectMachine); onhandle = true; return; } ObjView view; if (colli.name == "colli") { view = colli.transform.parent.GetComponent <ObjView>(); } else { view = colli.GetComponent <ObjView>(); } if (view != null && view == viewTarget) { canMove = true; } } else if (touch.phase == TouchPhase.Moved) { moved = true; } else if (touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended) { onhandle = false; if (moved == true) { return; } if (colli == null) { changed = true; setState(FreeState3D.NAME); return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { return; } ObjView view; if (colli.name == "colli") { view = colli.transform.parent.GetComponent <ObjView>(); } else { view = colli.GetComponent <ObjView>(); } if (view == null) { changed = true; setState(FreeState3D.NAME); return; } else if (view == viewTarget) { } else { changed = true; string stateName = view.GetState(); SelectState3D state = getSelectState3D(stateName); if (state == null) { return; } state.viewTarget = view; setState(stateName); } } }
public override void mUpdate() { base.mUpdate(); if (Input.GetMouseButtonDown(0) == true && uguiHitUI.uiHited == false) { canMove = false; onhandle = false; dowmPos = Input.mousePosition; colli = null; Ray ray = inputCamera.ScreenPointToRay(dowmPos); //RaycastHit hit; //bool hited = Physics.Raycast(ray, out hit); //if (hited == false) //{ // colli = null; // //setState(FreeState3D.NAME); // return; //} //colli = hit.collider; int count = Physics.RaycastNonAlloc(ray, raycastArr); if (count > 0) { raycastList.Clear(); for (int i = 0; i < count; i++) { raycastList.Add(raycastArr[i]); } // raycastList.Sort( // delegate (RaycastHit hit1, RaycastHit hit2) // { // if (hit1.distance > hit2.distance) return 1; // else return -1; // } //); SortDis(raycastList); float rayhitdis = float.MaxValue; for (int i = 0; i < count; i++) { if (colli != null && raycastList[i].distance > raycastList[0].distance + 5) { break; } float dis; bool hit = raycastFunc.RaycastMesh(Input.mousePosition, raycastList[i].collider.gameObject, out dis); if (hit == true) { if (dis < rayhitdis) { colli = raycastList[i].collider; rayhitdis = dis; } } } if (colli == null) { colli = raycastList[0].collider; } } if (colli == null) { return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { handle.SetState(selectMachine); onhandle = true; return; } ObjView view; if (colli.name == "colli") { view = colli.transform.parent.GetComponent <ObjView>(); } else { view = colli.GetComponent <ObjView>(); } if (view == null) { } if (view == viewTarget) { canMove = true; } } else if (Input.GetMouseButtonUp(0) == true) { onhandle = false; if (uguiHitUI.uiHited == true) { return; } Collider colli2; Vector2 upPos = Input.mousePosition; if (Vector2.Distance(dowmPos, upPos) > 5f) { return; } colli2 = null; Ray ray = inputCamera.ScreenPointToRay(upPos); //RaycastHit hit; //bool hited = Physics.Raycast(ray, out hit); //if (hited == false) //{ // colli2 = null; // if (colli == colli2) // { // changed = true; // setState(FreeState3D.NAME); // } // return; //} //colli2 = hit.collider; int count = Physics.RaycastNonAlloc(ray, raycastArr); if (count > 0) { raycastList.Clear(); for (int i = 0; i < count; i++) { raycastList.Add(raycastArr[i]); } // raycastList.Sort( // delegate (RaycastHit hit1, RaycastHit hit2) // { // if (hit1.distance > hit2.distance) return 1; // else return -1; // } //); SortDis(raycastList); float rayhitdis = float.MaxValue; for (int i = 0; i < count; i++) { if (colli != null && raycastList[i].distance > raycastList[0].distance + 5) { break; } float dis; bool hit = raycastFunc.RaycastMesh(Input.mousePosition, raycastList[i].collider.gameObject, out dis); if (hit == true) { if (dis < rayhitdis) { colli2 = raycastList[i].collider; rayhitdis = dis; } } } if (colli2 == null) { colli2 = raycastList[0].collider; } } if (colli2 == null) { if (colli == colli2) { changed = true; setState(FreeState3D.NAME); } return; } if (colli2 != colli) { return; } HandleView handle = colli.GetComponent <HandleView>(); if (handle != null) { return; } ObjView view; if (colli2.name == "colli") { view = colli2.transform.parent.GetComponent <ObjView>(); } else { view = colli2.GetComponent <ObjView>(); } if (view == null) { changed = true; setState(FreeState3D.NAME); return; } else if (view == viewTarget) { //canMove = true; //return; } else { changed = true; string stateName = view.GetState(); SelectState3D state = getSelectState3D(stateName); if (state == null) { return; } state.viewTarget = view; setState(stateName); } } }