public void CreateNewDataField(int type, DataBlockHolder dataBlockHolder) { if (type == 0) { GameObject newInfoDataField = Instantiate(infoInputField, dataBlockHolder.inputFieldHolder.position, Quaternion.identity); newInfoDataField.transform.SetParent(dataBlockHolder.inputFieldHolder); newInfoDataField.transform.localScale = Vector3.one; newInfoDataField.GetComponent <DataFieldHolder>().myDataField = new DataField { iD = newInfoDataField.GetInstanceID(), type = (int)newInfoDataField.GetComponent <InputFieldType>().type }; dataBlockHolder.myDataBlock.myDataFields.Add(newInfoDataField.GetComponent <DataFieldHolder>().myDataField); } else if (type == 1) { GameObject newTitleDataField = Instantiate(titleInputField, dataBlockHolder.inputFieldHolder.position, Quaternion.identity); newTitleDataField.transform.SetParent(dataBlockHolder.inputFieldHolder); newTitleDataField.transform.localScale = Vector3.one; newTitleDataField.GetComponent <DataFieldHolder>().myDataField = new DataField() { iD = newTitleDataField.GetComponent <DataFieldHolder>().myDataField.iD, type = (int)newTitleDataField.GetComponent <InputFieldType>().type }; dataBlockHolder.myDataBlock.myDataFields.Add(newTitleDataField.GetComponent <DataFieldHolder>().myDataField); } dataBlockHolder.IncreaseSize(); StartCoroutine(dataBlockHolder.CloseOptions()); }
public void OpenFolder() { ResetPanelScroll(); StructureManager.currentDataFolder = myDataFolder; if (DataCreationManager.instance.infoBlockHolder.childCount > 0) { for (int i = 0; i < DataCreationManager.instance.infoBlockHolder.childCount; i++) { Destroy(DataCreationManager.instance.infoBlockHolder.GetChild(i).gameObject); } } for (int i = 0; i < myDataFolder.myDataBlocks.Count; i++) { GameObject newDataBlock = Instantiate(DataCreationManager.instance.infoBlock, DataCreationManager.instance.infoBlockHolder.position, Quaternion.identity); newDataBlock.transform.SetParent(DataCreationManager.instance.infoBlockHolder); newDataBlock.transform.localScale = Vector3.one; DataBlockHolder dataBlock = newDataBlock.GetComponent <DataBlockHolder>(); dataBlock.myDataBlock = myDataFolder.myDataBlocks[i]; for (int ii = 0; ii < dataBlock.myDataBlock.myDataFields.Count; ii++) { if (dataBlock.myDataBlock.myDataFields[ii].type == 0) { GameObject newInfoDataField = Instantiate(DataCreationManager.instance.infoInputField, dataBlock.inputFieldHolder.position, Quaternion.identity); newInfoDataField.transform.SetParent(dataBlock.inputFieldHolder); newInfoDataField.transform.localScale = Vector3.one; newInfoDataField.GetComponent <DataFieldHolder>().myDataField = dataBlock.myDataBlock.myDataFields[ii]; } else if (dataBlock.myDataBlock.myDataFields[ii].type == 1) { GameObject newTitleDataField = Instantiate(DataCreationManager.instance.titleInputField, dataBlock.inputFieldHolder.position, Quaternion.identity); newTitleDataField.transform.SetParent(dataBlock.inputFieldHolder); newTitleDataField.transform.localScale = Vector3.one; newTitleDataField.GetComponent <DataFieldHolder>().myDataField = dataBlock.myDataBlock.myDataFields[ii]; } dataBlock.IncreaseSize(); } dataBlock.Initialize(); } StructureManager.instance.infoBlockPanel.SetActive(true); }
public void DeleteDataField() { DataBlockHolder topParent = transform.parent.GetComponentInParent <DataBlockHolder>(); for (int i = 0; i < topParent.myDataBlock.myDataFields.Count; i++) { if (myDataField.iD == topParent.myDataBlock.myDataFields[i].iD) { topParent.myDataBlock.myDataFields.Remove(topParent.myDataBlock.myDataFields[i]); topParent.DecreaseSize(); Destroy(gameObject); } } }