public string ToJson() { string str = ""; for (int i = 0; i < keyDatas.Count; i++) { str += keyDatas[i].ToJson(); if (i == keyDatas.Count - 1) { continue; } str += ","; } string str2 = ""; for (int i = 0; i < eventDatas.Count; i++) { str2 += eventDatas[i].ToJson(); if (i == eventDatas.Count - 1) { continue; } str2 += ","; } str = string.Format("{0},{1},{2}", StringHelper.KeyValueTojson("name", StringHelper.AddDoubleQuotation(name)) , StringHelper.KeyValueTojson("keys", StringHelper.AddBracket(str)) , StringHelper.KeyValueTojson("events", StringHelper.AddBracket(str2))); return(StringHelper.AddBrace(StringHelper.AddNewLine(str))); }
public string ToJson() { Int2 pos = position; Int2 localPos = localPosition; Float2 piv = pivot; pos.y *= -1; localPos.y *= -1; piv.y = 1 - piv.y; string str = string.Format("{0},{1},{2},{3},{4},{5}", StringHelper.KeyValueTojson("name", StringHelper.AddDoubleQuotation(name)), StringHelper.KeyValueTojson("visible", StringHelper.AddDoubleQuotation(go.activeSelf.ToString().ToLower())), StringHelper.KeyValueTojson("position", pos), StringHelper.KeyValueTojson("localPosition", localPos), StringHelper.KeyValueTojson("pivot", piv), StringHelper.KeyValueTojson("scale", scale)); if (component != null) { str += string.Format(",{0}", StringHelper.KeyValueTojson(component.name, component.ToJson())); } string cStr = ""; if (children.Count > 0) { for (int i = 0; i < children.Count; i++) { cStr += children[i].ToJson(); if (i == children.Count - 1) { continue; } cStr += ",\n"; } } str += "," + StringHelper.KeyValueTojson("children", StringHelper.AddBracket(cStr)); return(StringHelper.AddBrace(str)); }
public override string ToJson() { string str = ""; for (int i = 0; i < toggles.Length; i++) { str += StringHelper.AddBrace(string.Format("{0},{1}" , StringHelper.KeyValueTojson("buttonName", StringHelper.AddDoubleQuotation(toggles[i].button.name)) , StringHelper.KeyValueTojson("onImageName", StringHelper.AddDoubleQuotation(toggles[i].onImage.name)))); if (i == toggles.Length - 1) { continue; } str += ","; } str = string.Format("{0},{1}" , StringHelper.KeyValueTojson("defaultIndex", defaultIndex) , StringHelper.KeyValueTojson("toggles", StringHelper.AddBracket(str))); return(StringHelper.AddBrace(str)); }
public static string ToJson(Transform root) { List <UIData> uiDatas = new List <UIData>(); int count = root.transform.childCount; for (int i = 0; i < count; i++) { uiDatas.Add(new UIData(root, root.transform.GetChild(i))); } string str = ""; for (int i = 0; i < uiDatas.Count; i++) { str += uiDatas[i].ToJson(); if (i == uiDatas.Count - 1) { continue; } str += ",\n"; } return(StringHelper.AddBracket(str)); }
public string ToJson() { string str = string.Format("{0},{1},", StringHelper.KeyValueTojson("path", StringHelper.AddDoubleQuotation(path)) , StringHelper.KeyValueTojson("property", StringHelper.AddDoubleQuotation(property))); string keyString = ""; for (int i = 0; i < keys.Count; i++) { keyString += keys[i].ToJson(); if (i == keys.Count - 1) { continue; } keyString += ","; } keyString = StringHelper.AddBracket(keyString); str += StringHelper.KeyValueTojson("keys", keyString); return(StringHelper.AddBrace(str)); }