Exemplo n.º 1
0
 public void saveSheet(bool instance = false)
 {
     if (instance)
     {
         sheet = gameObject.GetComponent <SheetLoader>().getSheet();
         sheet.setInstance(instanceName.GetComponent <Text>().text);
         Debug.Log("Attempting save");
         SheetFileManager.saveSheetToFile(sheet, true);
     }
     else
     {
         n = sheetName.GetComponent <Text>().text;
         if (n != "")
         {
             if (!nameSet)
             {
                 sheet.setName(n);
             }
             else if (n != sheetName.GetComponent <Text>().text)
             {
                 sheet.setName(n);
             }
             Debug.Log("Attempting save");
             SheetFileManager.saveSheetToFile(sheet);
         }
     }
 }
Exemplo n.º 2
0
    public void generateSheet(string fileName, bool template = false)
    {
        sheet = SheetFileManager.loadSheetFromFile(fileName);
        if (!template)
        {
            sheet.setInstance(instance.Split('.')[1]);
        }

        GameObject field;

        foreach (KeyValuePair <string, (string, float, float, float, float)> tuple in sheet.getTextFields())
        {
            if (tuple.Value.Item1 == "")
            {
                field = Instantiate(label, transform);
                if (template)
                {
                    field.GetComponent <FieldManager>().setSheet(sheet, tuple.Key, tuple.Value.Item2, tuple.Value.Item3);
                    field.GetComponent <DragHandler>().dropLocation = gameObject;
                    field.GetComponent <InputField>().text          = tuple.Key;
                }
                else
                {
                    field.GetComponent <Text>().text = tuple.Key;
                }
                field.GetComponent <RectTransform>().localPosition = new Vector3(tuple.Value.Item2, tuple.Value.Item3, 0);
            }
            else
            {
                field = Instantiate(text, transform);
                if (template)
                {
                    field.GetComponent <FieldManager>().setSheet(sheet, tuple.Key, tuple.Value.Item1, tuple.Value.Item2, tuple.Value.Item3);
                    field.GetComponent <DragHandler>().dropLocation = gameObject;
                    field.GetComponent <FieldManager>().setSheet(sheet, tuple.Key, tuple.Value.Item1, tuple.Value.Item2, tuple.Value.Item3);
                    field.GetComponent <DragHandler>().dropLocation = gameObject;
                    field.GetComponent <InputField>().text          = tuple.Value.Item1;
                    field.GetComponent <Holder>().held.GetComponent <InputField>().text = tuple.Key;
                }
                else
                {
                    field.GetComponent <Holder>().held1.GetComponent <InputField>().text = tuple.Value.Item1;
                    field.GetComponent <Holder>().held.GetComponent <Text>().text        = tuple.Key;
                }
                field.GetComponent <RectTransform>().localPosition = new Vector3(tuple.Value.Item2, tuple.Value.Item3, 0);
            }
        }

        foreach (KeyValuePair <string, (float, float, float, float, float)> tuple in sheet.getStaticNumericalFields())
        {
            field = Instantiate(stat, transform);
            if (template)
            {
                field.GetComponent <FieldManager>().setSheet(sheet, tuple.Key, tuple.Value.Item1, tuple.Value.Item2, tuple.Value.Item3);
                field.GetComponent <DragHandler>().dropLocation = gameObject;
                field.GetComponent <Holder>().held1.GetComponent <InputField>().text = tuple.Key;
                field.GetComponent <InputField>().text = tuple.Value.Item1.ToString();
            }
            else
            {
                field.GetComponent <Text>().text = tuple.Key;
                field.GetComponent <Holder>().held.GetComponent <Text>().text = tuple.Value.Item1.ToString();
            }
            field.GetComponent <RectTransform>().localPosition = new Vector3(tuple.Value.Item2, tuple.Value.Item3, 0);
        }

        foreach (KeyValuePair <string, (float, float, float, float, float, float)> tuple in sheet.getDynamicNumericalFields())
        {
            field = Instantiate(dyn, transform);
            if (template)
            {
                field.GetComponent <FieldManager>().setSheet(sheet, tuple.Key, tuple.Value.Item1, tuple.Value.Item2, tuple.Value.Item3, tuple.Value.Item4);
                field.GetComponent <DragHandler>().dropLocation = gameObject;
                field.GetComponent <Holder>().held2.GetComponent <InputField>().text = tuple.Key;
                field.GetComponent <Holder>().held.GetComponent <InputField>().text  = tuple.Value.Item1.ToString();
                field.GetComponent <Holder>().held1.GetComponent <InputField>().text = tuple.Value.Item2.ToString();
            }
            else
            {
                field.GetComponent <Text>().text = tuple.Key;
                field.GetComponent <Holder>().held.GetComponent <InputField>().text = tuple.Value.Item1.ToString();
                field.GetComponent <Holder>().held1.GetComponent <Text>().text      = tuple.Value.Item2.ToString();
            }

            field.GetComponent <RectTransform>().localPosition = new Vector3(tuple.Value.Item3, tuple.Value.Item4, 0);
        }
    }