Пример #1
0
        public static DataFile Create(object dataFile)
        {
            System.Type type          = dataFile.GetType();
            string      directoryPath = Application.dataPath + "/Generated/" + type;
            string      newFilename   = System.String.Format(type + "-{0}.txt", System.DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss"));
            DataFile    df            = new DataFile(new FileInfo(directoryPath + "/" + newFilename), dataFile);

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }
            File.WriteAllText(directoryPath + "/" + newFilename, df.ToJson());
            return(df);
        }
Пример #2
0
        void Awake()
        {
            string[] options = Helper.GetTypesWithHelpAttribute().Select(x => x.ToString()).ToArray();
            dataForm      = new DataForm("Data Form", options[0], Rect.MinMaxRect(Screen.width * 0.05f, Screen.height * 0.05f, Screen.width * 0.75f, Screen.height * 0.95f), 0);
            createData    = new CreateData(options, "Create Data", Rect.MinMaxRect(Screen.width * 0.77f, Screen.height * 0.05f, Screen.width * 0.95f, Screen.height * 0.5f), 1);
            fileHierarchy = new FileHierarchy("File Hierarchy", Rect.MinMaxRect(Screen.width * 0.77f, Screen.height * 0.52f, Screen.width * 0.95f, Screen.height * 0.95f), 2);
            fileHierarchy.SetOption(dataForm.SetField);
            createData.onCreateDataFile.AddListener((index, name) =>
            {
                DataFile.Create(System.Activator.CreateInstance(System.Type.GetType(name)));
                fileHierarchy.Refresh();
            });

            fileHierarchy.Refresh();

            if (fileHierarchy.files.Length > 0)
            {
                fileHierarchy.selectionGrid.SetSelection(0);
            }
        }
Пример #3
0
 public static void Ammend(DataFile dataFile)
 {
     Debug.Log("Ammend");
     File.WriteAllText(dataFile.fileInfo.FullName, dataFile.ToJson());
 }
Пример #4
0
 public void Refresh()
 {
     files = DataFile.LoadAll();
     selectionGrid.options = files.Select(x => System.IO.Path.GetFileNameWithoutExtension(x.fileInfo.Name)).ToArray();
 }