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); }
public IEnumerator LoadUUebTags(string uriSource) { if (IsLoadingUUebTags) { throw new Exception("multiple uuebTags description found. only one uuebTags description is valid."); } var schemeEndIndex = uriSource.IndexOf("//"); var scheme = uriSource.Substring(0, schemeEndIndex); IsLoadingUUebTags = true; Action<UUebTags> succeeded = uuebTags => { this.uuebTags = uuebTags; this.customTagTypeDict = this.uuebTags.GetTagTypeDict(); // レイヤー名:constraintsの辞書を生成しておく。 this.layerDict = new Dictionary<string, BoxConstraint[]>(); this.unboxedLayerSizeDict = new Dictionary<string, BoxPos>(); var layerInfos = uuebTags.layerInfos; foreach (var layerInfo in layerInfos) { layerDict[layerInfo.layerName.ToLower()] = layerInfo.boxes; unboxedLayerSizeDict[layerInfo.layerName.ToLower()] = layerInfo.unboxedLayerSize; } IsLoadingUUebTags = false; }; Action<int, string> failed = (code, reason) => { throw new Exception("未対処なリストのロードエラー。failed to load uuebTags. code:" + code + " reason:" + reason + " from:" + uriSource); this.uuebTags = new UUebTags(ConstSettings.UUEBTAGS_DEFAULT, new ContentInfo[0], new LayerInfo[0]);// set empty list. IsLoadingUUebTags = false; }; IEnumerator cor = null; switch (scheme) { case "assetbundle:": { cor = LoadTagsFromAssetBundle(uriSource, succeeded, failed); break; } case "https:": case "http:": { cor = LoadTagsFromWeb(uriSource, succeeded, failed); break; } case "resources:": { var resourcePath = uriSource.Substring("resources:".Length + 2); cor = LoadTagsFromResources(resourcePath, succeeded, failed); break; } default: {// other. throw new Exception("unsupported scheme found, scheme:" + scheme); } } while (cor.MoveNext()) { yield return null; } }