private void InitPlayAreaCursor() { int btmRight = 4; int topLeft = 6; float width = playArea.vertices[btmRight].x - playArea.vertices[topLeft].x; float length = playArea.vertices[topLeft].z - playArea.vertices[btmRight].z; float height = 0.01f; playAreaCursor = GameObject.CreatePrimitive(PrimitiveType.Cube); playAreaCursor.name = "PlayerObject_WorldPointer_PlayAreaCursor"; playAreaCursor.transform.parent = null; playAreaCursor.transform.localScale = new Vector3(width, height, length); playAreaCursor.SetActive(false); playAreaCursor.GetComponent <MeshRenderer>().enabled = false; BoxCollider playAreaCursorCollider = playAreaCursor.GetComponent <BoxCollider>(); playAreaCursorCollider.isTrigger = true; playAreaCursorCollider.center = new Vector3(0f, 65f, 0f); playAreaCursorCollider.size = new Vector3(1f, 100f, 1f); playAreaCursor.AddComponent <Rigidbody>().isKinematic = true; SteamVR_PlayAreaCollider playAreaCursorScript = playAreaCursor.AddComponent <SteamVR_PlayAreaCollider>(); playAreaCursorScript.SetParent(this.gameObject); playAreaCursor.layer = 2; float playAreaBoundaryX = playArea.transform.localScale.x / 2; float playAreaBoundaryZ = playArea.transform.localScale.z / 2; float heightOffset = 0f; DrawPlayAreaCursorBoundary(0, playArea.vertices[5].x, playArea.vertices[4].x, playArea.vertices[0].z, playArea.vertices[4].z, height, new Vector3(0f, heightOffset, playAreaBoundaryZ)); DrawPlayAreaCursorBoundary(1, playArea.vertices[5].x, playArea.vertices[1].x, playArea.vertices[6].z, playArea.vertices[5].z, height, new Vector3(playAreaBoundaryX, heightOffset, 0f)); DrawPlayAreaCursorBoundary(2, playArea.vertices[5].x, playArea.vertices[4].x, playArea.vertices[0].z, playArea.vertices[4].z, height, new Vector3(0f, heightOffset, -playAreaBoundaryZ)); DrawPlayAreaCursorBoundary(3, playArea.vertices[5].x, playArea.vertices[1].x, playArea.vertices[6].z, playArea.vertices[5].z, height, new Vector3(-playAreaBoundaryX, heightOffset, 0f)); }
private void InitPlayAreaCursor() { int btmRightInner = 0; int btmLeftInner = 1; int topLeftInner = 2; int topRightInner = 3; int btmRightOuter = 4; int btmLeftOuter = 5; int topLeftOuter = 6; int topRightOuter = 7; Vector3[] cursorDrawVertices = playArea.vertices; if (playAreaCursorDimensions != Vector2.zero) { float customAreaPadding = playArea.borderThickness; cursorDrawVertices[btmRightOuter] = new Vector3(playAreaCursorDimensions.x / 2, 0f, (playAreaCursorDimensions.y / 2) * -1); cursorDrawVertices[btmLeftOuter] = new Vector3((playAreaCursorDimensions.x / 2) * -1, 0f, (playAreaCursorDimensions.y / 2) * -1); cursorDrawVertices[topLeftOuter] = new Vector3((playAreaCursorDimensions.x / 2) * -1, 0f, playAreaCursorDimensions.y / 2); cursorDrawVertices[topRightOuter] = new Vector3(playAreaCursorDimensions.x / 2, 0f, playAreaCursorDimensions.y / 2); cursorDrawVertices[btmRightInner] = cursorDrawVertices[btmRightOuter] + new Vector3(-customAreaPadding, 0f, customAreaPadding); cursorDrawVertices[btmLeftInner] = cursorDrawVertices[btmLeftOuter] + new Vector3(customAreaPadding, 0f, customAreaPadding); cursorDrawVertices[topLeftInner] = cursorDrawVertices[topLeftOuter] + new Vector3(customAreaPadding, 0f, -customAreaPadding); cursorDrawVertices[topRightInner] = cursorDrawVertices[topRightOuter] + new Vector3(-customAreaPadding, 0f, -customAreaPadding); } float width = cursorDrawVertices[btmRightOuter].x - cursorDrawVertices[topLeftOuter].x; float length = cursorDrawVertices[topLeftOuter].z - cursorDrawVertices[btmRightOuter].z; float height = 0.01f; playAreaCursor = GameObject.CreatePrimitive(PrimitiveType.Cube); playAreaCursor.name = string.Format("[{0}]PlayerObject_WorldPointer_PlayAreaCursor", this.gameObject.name); playAreaCursor.transform.parent = null; playAreaCursor.transform.localScale = new Vector3(width, height, length); playAreaCursor.SetActive(false); playAreaCursor.GetComponent <MeshRenderer>().enabled = false; BoxCollider playAreaCursorCollider = playAreaCursor.GetComponent <BoxCollider>(); playAreaCursorCollider.isTrigger = true; playAreaCursorCollider.center = new Vector3(0f, 65f, 0f); playAreaCursorCollider.size = new Vector3(1f, 100f, 1f); playAreaCursor.AddComponent <Rigidbody>().isKinematic = true; SteamVR_PlayAreaCollider playAreaCursorScript = playAreaCursor.AddComponent <SteamVR_PlayAreaCollider>(); playAreaCursorScript.SetParent(this.gameObject); playAreaCursor.layer = 2; float playAreaBoundaryX = playArea.transform.localScale.x / 2; float playAreaBoundaryZ = playArea.transform.localScale.z / 2; float heightOffset = 0f; DrawPlayAreaCursorBoundary(0, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmRightOuter].x, cursorDrawVertices[btmRightInner].z, cursorDrawVertices[btmRightOuter].z, height, new Vector3(0f, heightOffset, playAreaBoundaryZ)); DrawPlayAreaCursorBoundary(1, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmLeftInner].x, cursorDrawVertices[topLeftOuter].z, cursorDrawVertices[btmLeftOuter].z, height, new Vector3(playAreaBoundaryX, heightOffset, 0f)); DrawPlayAreaCursorBoundary(2, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmRightOuter].x, cursorDrawVertices[btmRightInner].z, cursorDrawVertices[btmRightOuter].z, height, new Vector3(0f, heightOffset, -playAreaBoundaryZ)); DrawPlayAreaCursorBoundary(3, cursorDrawVertices[btmLeftOuter].x, cursorDrawVertices[btmLeftInner].x, cursorDrawVertices[topLeftOuter].z, cursorDrawVertices[btmLeftOuter].z, height, new Vector3(-playAreaBoundaryX, heightOffset, 0f)); }