Exemple #1
0
 public void LoadAllYarns()
 {
     string [] fileEntries = Directory.GetFiles(Application.persistentDataPath + "/yarns", "*.yarn");
     foreach (string fileName in fileEntries)
     {
         ScriptableYarn sy = LoadYarn(fileName);
         dropdownYarns.CreateNewItem(sy.name, null);
     }
 }
Exemple #2
0
    public ScriptableYarn LoadYarn(string fileName)
    {
        ScriptableYarn scriptableYarn = null;

        if (File.Exists(fileName))
        {
            string json = File.ReadAllText(fileName);
            scriptableYarn = JsonConvert.DeserializeObject <ScriptableYarn>(json);
        }

        return(scriptableYarn);
    }
 public YarnPictorial(Pictorial copy)
 {
     if (copy.curve == null)
     {
         curve = null;
     }
     else
     {
         GameObject.Instantiate(copy.curve);
     }
     drawing       = copy.drawing;
     debugColor    = copy.debugColor;
     contour       = null;
     yarn          = copy.yarn;
     adjusted      = copy.adjusted;
     healedStep    = copy.healedStep;
     healedStepGap = copy.healedStepGap;
     doubleHealed  = copy.doubleHealed;
 }
Exemple #4
0
    public void SaveYarn(ScriptableYarn yarn)
    {
        if (!Directory.Exists(Application.persistentDataPath + "/yarns"))
        {
            Directory.CreateDirectory(Application.persistentDataPath + "/yarns");
        }

        JsonSerializerSettings jss = new JsonSerializerSettings();

        jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
        try
        {
            string json = JsonConvert.SerializeObject(yarn, jss);
            File.WriteAllText(Application.persistentDataPath + "/yarns/" + yarn.name + ".yarn", json);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }