void DestroyGestureGalleryGrids() { galleryState = GestureGalleryState.Visible; galleryRB.MovePosition(galleryStartPosition); for (int i = grids.Count - 1; i >= 0; i--) { grids[i].DestroyThisGrid(); } grids.Clear(); }
// INIT void Start() { canvasGroup = GetComponent <CanvasGroup>(); galleryStartPosition = transform.position; vrGestureUI = transform.parent.GetComponent <VRGestureUI>(); galleryRB = GetComponent <Rigidbody>(); galleryState = GestureGalleryState.NotVisible; //frameOffset = new Vector3(gridUnitSize / 4, gridUnitSize / 4, -(gridUnitSize / 2)); frameOffset = new Vector3(0, gridUnitSize / 6, -(gridUnitSize / 2)); GetHands(); }
// INIT void Start() { gestureSettings = Utils.GetGestureSettings(); galleryPosition = new Vector3(0, 90, 0); canvasGroup = GetComponent <CanvasGroup>(); galleryStartPosition = transform.position; vrGestureUI = transform.parent.GetComponent <VRGestureUI>(); galleryRB = GetComponent <Rigidbody>(); galleryState = GestureGalleryState.NotVisible; GetHands(); }
void DestroyGestureGallery() { // get all children var children = new List <GameObject>(); foreach (Transform child in transform) { children.Add(child.gameObject); } // remove things I don't want to destroy children.Remove(instructions.gameObject); // un-enable those things instructions.gameObject.SetActive(false); // destroy the rest children.ForEach(child => Destroy(child)); galleryState = GestureGalleryState.Visible; galleryRB.MovePosition(galleryStartPosition); }
void GenerateGestureGallery() { float xPos = 0; float yPos = 0; int column = 0; int row = 0; // draw gesture at position float gridStartPosX = (gridUnitSize * gridMaxColumns) / 2; int gridMaxRows = examples.Count / gridMaxColumns; float gridStartPosY = (gridUnitSize * gridMaxRows) / 2; // go through all the gesture examples and draw them in a grid for (int i = 0; i < examples.Count; i++) { // set the next position xPos = column * gridUnitSize; yPos = -row * gridUnitSize; // offset positions to center the transform xPos -= gridStartPosX; yPos += gridStartPosY; Vector3 localPos = new Vector3(xPos, yPos, 0); // draw the gesture GameObject gestureLine = DrawGesture(examples[i].data, localPos, i); // draw the frame Vector3 framePos = localPos + frameOffset; GameObject frame = GameObject.Instantiate(framePrefab) as GameObject; frame.transform.parent = transform; frame.transform.localPosition = framePos; frame.transform.localRotation = Quaternion.identity; frame.name = "Frame " + i; frame.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, gridUnitSize); frame.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, gridUnitSize); Button frameButton = frame.GetComponent <Button>(); GestureExample example = examples[i]; GameObject lineObj = gestureLine; frameButton.onClick.AddListener(() => CallDeleteGesture(example, frame, lineObj)); // set the trash icon position VRGestureGalleryFrame frameScript = frame.GetComponent <VRGestureGalleryFrame>(); RectTransform trashTF = (RectTransform)frameScript.trash.transform; frameScript.trash.transform.localPosition = Vector3.zero; trashTF.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, gridUnitSize * 2); trashTF.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, gridUnitSize * 2); // change column or row column += 1; if (column >= gridMaxColumns) { column = 0; row += 1; } } // instructions adjust // needs work float instructionsPosY = ((row + 1) * gridUnitSize); instructions.localPosition = new Vector3(0, instructionsPosY, 0); galleryState = GestureGalleryState.Visible; }