private void Load() { TextAsset textAsset = Resources.Load("ProceduralGeneration/DynamicTags") as TextAsset; attributes = JsonUtility.FromJson <FuzzyAttributes> (textAsset.text); UpdateNameList(); }
private void CreateXML() { TextAsset textAsset = Resources.Load("FuzzyAttributes") as TextAsset; FuzzyAttributes oldAttr = JsonUtility.FromJson <FuzzyAttributes> (textAsset.text); FuzzyAttributes attributes = new FuzzyAttributes(); attributes.attributes = new FuzzyAttribute[oldAttr.attributes.Length]; for (int i = 0; i < attributes.attributes.Length; i++) { attributes.attributes [i] = new FuzzyAttribute(); attributes.attributes [i].name = oldAttr.attributes [i].name; attributes.attributes [i].descriptors = new FuzzyDescriptor[oldAttr.attributes [i].attributes.Length]; for (int j = 0; j < attributes.attributes[i].descriptors.Length; j++) { attributes.attributes [i].descriptors [j] = new FuzzyDescriptor(); attributes.attributes [i].descriptors [j].name = oldAttr.attributes [i].attributes [j]; attributes.attributes [i].descriptors [j].value = UnityEngine.Random.value; } } string serialized = JsonUtility.ToJson(attributes, true); string path = Application.dataPath + "/Resources/newjson.json"; Debug.Log(path); File.WriteAllText(path, serialized); }
private static void LoadDictionary() { TextAsset textAsset = Resources.Load("ProceduralGeneration/DynamicTags") as TextAsset; if (oldFile != textAsset.text) { oldFile = textAsset.text; FuzzyAttributes attributes = JsonUtility.FromJson <FuzzyAttributes> (textAsset.text); mapping = new Dictionary <string, List <FuzzyDescriptor> > (); foreach (FuzzyAttribute attribute in attributes.attributes) { List <FuzzyDescriptor> descriptors = attribute.descriptors.OrderBy(d => d.value).ToList(); descriptors [descriptors.Count - 1].value = 1f; mapping.Add(attribute.name, descriptors); } } }