Пример #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);
         }
     }
 }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        InfoSheet sheet = new InfoSheet("1");

        sheet.dynamicNumericalFields.Add("Dynamic1", (1, 2, 3, 4, 5, 6));
        sheet.dynamicNumericalFields.Add("Dynamic2", (1, 2, 3, 4, 5, 6));
        sheet.dynamicNumericalFields.Add("Dynamic3", (1, 2, 3, 4, 5, 6));
        sheet.staticNumericalFields.Add("Static1", (5, 2, 3, 4, 5));
        sheet.staticNumericalFields.Add("Static2", (1, 2, 3, 4, 5));
        sheet.staticNumericalFields.Add("Static3", (1, 2, 3, 4, 5));
        sheet.textFields.Add("Name", ("Test1", 1, 2, 3, 4));
        sheet.textFields.Add("Text2", ("Test", 1, 2, 3, 4));
        sheet.textFields.Add("Text3", ("Test", 1, 2, 3, 4));

        SheetFileManager.saveSheetToFile(sheet);

        InfoSheet sheet2 = SheetFileManager.loadSheetFromFile(@"Sheets\" + "1" + ".st");

        sheet2.setName("2");
        SheetFileManager.saveSheetToFile(sheet2);
    }
Пример #3
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);
        }
    }