Example #1
0
    public void Load()
    {
        Debug.Log(Path.Combine(UnityEngine.Application.persistentDataPath, FolderName));

        for (int i = 0; i < windowSizes.Length; i++)
        {
            string fullPath = Path.Combine(UnityEngine.Application.persistentDataPath, FolderName, $"{FileName}_L{i}{Extension}");
            if (File.Exists(fullPath))
            {
                string jsonString = File.ReadAllText(fullPath);
                SerializableTransformList transformList = JsonUtility.FromJson <SerializableTransformList>(jsonString);

                // first element is always the root transform (WindowSize_LX)
                SerializeUtilities.DeserializeTransform(transformList.TransformList[0], windowSizes[i].transform);
                Transform[] transforms = windowSizes[i].GetComponentsInChildren <Transform>();

                int transformIndex = 1; // skip the first entry
                for (int j = 0; j < transforms.Length; j++)
                {
                    if (transforms[j].tag.Equals("StencilMask"))
                    {
                        SerializeUtilities.DeserializeTransform(transformList.TransformList[transformIndex], transforms[j]);
                        transformIndex++;
                    }
                }
            }
        }
    }