private static void Antimaterialize(GameObject target) { var viewName = target.name; var exportBasePath = ConstSettings.FULLPATH_INFORMATION_RESOURCE + viewName; Debug.Log("start antimaterialize:" + viewName + ". view name is:" + target + " export file path:" + exportBasePath); // remove all files in exportBasePath. FileController.RemakeDirectory(exportBasePath); // childrenがいろいろなタグの根本にあたる。 var layersInEditor = new List <LayerInfoOnEditor>(); var contents = new List <ContentInfo>(); var rectTrans = target.GetComponent <RectTransform>(); if ( rectTrans.anchorMin.x == 0 && rectTrans.anchorMin.y == 1 && rectTrans.anchorMax.x == 0 && rectTrans.anchorMax.y == 1 && rectTrans.pivot.x == 0 && rectTrans.pivot.y == 1 ) { // pass. } else { throw new Exception("root gameObject should have rectTrans.anchorMin:(0,1) ectTrans.anchorMax:(0,1) rectTrans.pivot:(0,1) anchor. please set it."); } var rootWidth = rectTrans.sizeDelta.x; var rootHeight = rectTrans.sizeDelta.y; // recursiveに、コンテンツを分解していく。 for (var i = 0; i < target.transform.childCount; i++) { var child = target.transform.GetChild(i); CollectLayerConstraintsAndContents(viewName, child.gameObject, layersInEditor, contents, rootWidth, rootHeight); } // 存在するlayer内の要素に対して、重なっているもの、縦に干渉しないものをグループとして扱う。 foreach (var currentLayer in layersInEditor) { if (currentLayer.layerInfo.boxes.Any()) { CollectCollisionInLayer(currentLayer); } } var UUebTags = new UUebTags(viewName, contents.ToArray(), layersInEditor.Select(l => l.layerInfo).ToArray()); var jsonStr = JsonUtility.ToJson(UUebTags); using (var sw = new StreamWriter(Path.Combine(exportBasePath, ConstSettings.listFileName))) { sw.WriteLine(jsonStr); } AssetDatabase.Refresh(); Debug.Log("finished antimaterialize:" + viewName + ". view name is:" + target + " export file path:" + exportBasePath); }
private static void Antimaterialize(GameObject target) { Debug.Log("start tag-generation check."); var childNames = GetChildNames(target); // 名前の重複チェック var overlappedNameList = childNames.GroupBy(n => n).Where(c => 1 < c.Count()).ToList(); if (0 < overlappedNameList.Count) { Debug.LogError("two or multiple gameobject has same name. please set unique name for converting gameobject to HTML tag."); foreach (var name in overlappedNameList) { Debug.LogError("gameobject name:" + name + " is defined multiple times. please change for each object name to unique."); } return; } var viewName = target.name; var exportBasePath = ConstSettings.FULLPATH_INFORMATION_RESOURCE + viewName; Debug.Log("start antimaterialize:" + viewName + ". view name is:" + target + " export file path:" + exportBasePath); // remove all files in exportBasePath. FileController.RemakeDirectory(exportBasePath); // childrenがいろいろなタグの根本にあたる。 var layersInEditor = new List <LayerInfoOnEditor>(); var contents = new List <ContentInfo>(); var rectTrans = target.GetComponent <RectTransform>(); if ( rectTrans.anchorMin.x == 0 && rectTrans.anchorMin.y == 1 && rectTrans.anchorMax.x == 0 && rectTrans.anchorMax.y == 1 && rectTrans.pivot.x == 0 && rectTrans.pivot.y == 1 ) { // pass. } else { throw new Exception("root gameObject should have rectTrans.anchorMin:(0,1) ectTrans.anchorMax:(0,1) rectTrans.pivot:(0,1) anchor. please set it."); } var rootWidth = rectTrans.sizeDelta.x; var rootHeight = rectTrans.sizeDelta.y; // recursiveに、コンテンツを分解していく。 for (var i = 0; i < target.transform.childCount; i++) { var child = target.transform.GetChild(i); CollectLayerConstraintsAndContents(viewName, child.gameObject, layersInEditor, contents, rootWidth, rootHeight); } // 存在するlayer内の要素に対して、重なっているもの、縦に干渉しないものをグループとして扱う。 foreach (var currentLayer in layersInEditor) { if (currentLayer.layerInfo.boxes.Any()) { CollectCollisionInLayer(currentLayer); } } var UUebTags = new UUebTags(viewName, contents.ToArray(), layersInEditor.Select(l => l.layerInfo).ToArray()); var jsonStr = JsonUtility.ToJson(UUebTags); using (var sw = new StreamWriter(Path.Combine(exportBasePath, ConstSettings.listFileName))) { sw.WriteLine(jsonStr); } // オリジナルのオブジェクト自体をprefabとして別途保存する。 if (!Directory.Exists(exportBasePath + "/Editor/")) { Directory.CreateDirectory(exportBasePath + "/Editor/"); } PrefabUtility.CreatePrefab(exportBasePath + "/Editor/" + viewName + ".prefab", target); AssetDatabase.Refresh(); Debug.Log("finished antimaterialize:" + viewName + ". view name is:" + target + " export file path:" + exportBasePath); }