public static string CreateJson(GameObject obj, string jsonDataName, string ParentPath) { // My_UIEditorToos.InitProgress(obj.transform.GetChildCount()); JsonData jd = new JsonData(); JsonData RootpositionJson = new JsonData(); JsonData RootsizeDeltaJson = new JsonData(); JsonData jd2 = new JsonData(); int i = 0; foreach (Transform item in obj.transform) { JsonData tmp = new JsonData(); JsonData TransformJson = new JsonData(); JsonData positionJson = new JsonData(); JsonData sizeDeltaJson = new JsonData(); i++; tmp["PrefabName"] = item.name; positionJson["x"] = item.GetComponent <RectTransform>().localPosition.x; positionJson["y"] = item.GetComponent <RectTransform>().localPosition.y; positionJson["z"] = item.GetComponent <RectTransform>().localPosition.z; sizeDeltaJson["w"] = item.GetComponent <RectTransform>().sizeDelta.x; sizeDeltaJson["h"] = item.GetComponent <RectTransform>().sizeDelta.y; tmp["position"] = positionJson; tmp["sizeDelta"] = sizeDeltaJson; if (item.GetComponent <UIAnimation>() != null) { tmp["AnimationType"] = item.GetComponent <UIAnimation>().AnimationType; tmp["ScriptType"] = item.GetComponent <UIAnimation>().ScriptType; tmp["Direction"] = item.GetComponent <UIAnimation>().direction.ToString(); } if (item.GetComponent <SUIButton>() != null) { string s = item.GetComponent <SUIButton>().m_ButtonMsg.ToString(); tmp["ButtonEvent"] = "" + s; } else { tmp["ButtonEvent"] = ""; } jd2.Add(tmp); // My_UIEditorToos.Progress(); MyParent.make(item.gameObject, "Assets/Resources/UI/" + ParentPath + "/" + item.name + ".prefab"); } RootpositionJson["x"] = obj.GetComponent <RectTransform>().localPosition.x; RootpositionJson["y"] = obj.GetComponent <RectTransform>().localPosition.y; RootpositionJson["z"] = obj.GetComponent <RectTransform>().localPosition.z; RootsizeDeltaJson["w"] = obj.GetComponent <RectTransform>().sizeDelta.x; RootsizeDeltaJson["h"] = obj.GetComponent <RectTransform>().sizeDelta.y; jd["parentURL"] = ParentPath; jd["Name"] = obj.name; jd["position"] = RootpositionJson; jd["sizeDelta"] = RootsizeDeltaJson; jd["Child"] = jd2; Debug.Log(jd.ToJson()); string filepath = Application.dataPath + "/Resources"; My_UIEditorToos.CreateFile(filepath, jsonDataName, jd); return(filepath); }
static void CreateArrangement() { Debug.Log("" + Selection.activeGameObject.name); if (Selection.activeGameObject != null) { JsonData jd = new JsonData(); JsonData jd1 = new JsonData(); jd["Arrangement"] = "1.0.0.0"; foreach (Transform item in Selection.activeGameObject.transform) { JsonData tmp = new JsonData(); JsonData tmp1 = new JsonData(); JsonData tmp2 = new JsonData(); JsonData tmp3 = new JsonData(); JsonData tmp4 = new JsonData(); tmp2["x"] = item.transform.localPosition.x; tmp2["y"] = item.transform.localPosition.y; tmp2["z"] = item.transform.localPosition.z; tmp3["x"] = item.transform.localRotation.eulerAngles.x; tmp3["y"] = item.transform.localRotation.eulerAngles.y; tmp3["z"] = item.transform.localRotation.eulerAngles.z; tmp4["x"] = item.transform.localScale.x; tmp4["y"] = item.transform.localScale.y; tmp4["z"] = item.transform.localScale.z; tmp1["pos"] = tmp2; tmp1["pot"] = tmp3; tmp1["scale"] = tmp4; tmp["Transform"] = tmp1; jd1.Add(tmp); } jd["Array"] = jd1; My_UIEditorToos.CreateFile("Assets/Resources", "Arrangement", jd); Debug.Log("" + jd.ToJson()); } }