void Open() { TC_Settings settings = TC_Settings.instance; string folder = settings.lastPath; if (!folder.Contains(Application.dataPath)) { folder = ""; } if (folder == "") { folder = Application.dataPath + TC.installPath.Replace("Assets", "") + "/Examples/Presets/TerrainLayer"; } string path = EditorUtility.OpenFilePanel("Open TerrainComposer2 project", folder, "prefab"); if (path.Length != 0) { settings.lastPath = TC.GetPath(path); string filePath = TC.GetAssetDatabasePath(path); if (TC.FileExists(filePath)) { GameObject go = Instantiate(AssetDatabase.LoadAssetAtPath(filePath, typeof(GameObject))) as GameObject; if (go != null) { go.transform.hideFlags = HideFlags.HideInInspector; TC_TerrainLayer terrainLayer = go.GetComponent <TC_TerrainLayer>(); if (terrainLayer != null) { go.transform.parent = TC_Generate.instance.transform.parent; DestroyImmediate(TC_Area2D.current.terrainLayer.gameObject); TC_Area2D.current.terrainLayer = terrainLayer; DebugMode(); TC.AddMessage(TC.GetFileName(path) + " is loaded succesfully."); } else { TC.AddMessage("This is not a TerrainLayer prefab."); DestroyImmediate(go); } } } else { TC.AddMessage("Can't find path."); } } }
public TC_RawImage AddRawFile(string fullPath, bool isResourcesFolder) { for (int i = 0; i < rawFiles.Count; i++) { if (rawFiles[i] == null) { rawFiles.RemoveAt(i); i--; continue; } if (rawFiles[i].path == fullPath) { ++rawFiles[i].referenceCount; if (rawFiles[i].tex == null) { rawFiles[i].LoadRawImage(fullPath); } return(rawFiles[i]); } } string label = TC.GetFileName(fullPath); GameObject go = new GameObject(label); go.transform.parent = transform; TC_RawImage rawImage = go.AddComponent <TC_RawImage>(); // Debug.Log(fullPath); rawImage.isResourcesFolder = isResourcesFolder; rawImage.LoadRawImage(fullPath); rawImage.referenceCount = 1; rawFiles.Add(rawImage); return(rawImage); }