public void AlbumShapeEvent1(TableShape1 tableShape) { /* if (tableShape == null) { * return; * } * * TableShape.selectedShape = tableShape; * LoadGameScene (); */ }
/// <summary> /// Creates the shapes in Groups. /// </summary> private void CreateShapes() { if (ShapesManager1.instance == null) { return; } //Clear current shapes list shapes.Clear(); //The ID of the shape int ID = 0; GameObject shapesGroup = null; float contentScale = (Screen.width * 1.0f / Screen.height) * contentScaleRatio; //content scale //Create Shapes inside groups for (int i = 0; i < ShapesManager1.instance.shapes.Count; i++) { if (i % shapesPerGroup == 0) { int groupIndex = (i / shapesPerGroup); shapesGroup = Group1.CreateGroup(shapesGroupPrefab, groupsParent, groupIndex, columnsPerGroup); if (!EnableGroupGridLayout) { shapesGroup.GetComponent <GridLayoutGroup>().enabled = false; } if (createGroupsPointers) { Pointer.CreatePointer(groupIndex, shapesGroup, pointerPrefab, pointersParent); } } ID = (i + 1); //the ID of the shape //Create a Shape GameObject tableShapeGameObject = Instantiate(shapePrefab, Vector3.zero, Quaternion.identity) as GameObject; tableShapeGameObject.transform.SetParent(shapesGroup.transform); //setting up the shape's parent TableShape1 tableShapeComponent = tableShapeGameObject.GetComponent <TableShape1> (); //get TableShape Component tableShapeComponent.ID = ID; //setting up shape ID tableShapeGameObject.name = "Shape-" + ID; //shape name tableShapeGameObject.transform.localScale = Vector3.one; tableShapeGameObject.GetComponent <RectTransform> ().offsetMax = Vector2.zero; tableShapeGameObject.GetComponent <RectTransform> ().offsetMin = Vector2.zero; GameObject content = Instantiate(ShapesManager1.instance.shapes[i].gamePrefab1, Vector3.zero, Quaternion.identity) as GameObject; //release unwanted resources Destroy(content.GetComponent <EventTrigger>()); Destroy(content.GetComponent <UIEvents>()); if (content.transform.Find("Parts") != null) { Destroy(content.transform.Find("Parts").gameObject); } content.transform.SetParent(tableShapeGameObject.transform.Find("Content")); RectTransform rectTransform = tableShapeGameObject.transform.Find("Content").GetComponent <RectTransform>(); //set up the scale content.transform.localScale = new Vector3(contentScale, contentScale); //set up the anchor content.GetComponent <RectTransform> ().anchorMin = Vector2.zero; content.GetComponent <RectTransform> ().anchorMax = Vector2.one; //set up the offset content.GetComponent <RectTransform> ().offsetMax = Vector2.zero; content.GetComponent <RectTransform> ().offsetMin = Vector2.zero; //enable image component content.GetComponent <Image> ().enabled = true; //add click listener content.gameObject.SetActive(true); shapes.Add(tableShapeComponent); //add table shape component to the list } if (ShapesManager1.instance.shapes.Count == 0) { Debug.Log("There are no Shapes found"); } else { Debug.Log("New shapes have been created"); } }