public static WallSection CreateWallSection(string name = null, string directory = null) { WallSection wallSection = CreateInstance <WallSection>(); if (Application.isPlaying) { return(wallSection); } if (name != null) { wallSection.name = name; } #if UNITY_EDITOR if (directory == null) { UnityEditor.AssetDatabase.CreateAsset(wallSection, AssetCreator.GeneratePath("newWallSection.asset", "WallSections")); } else { UnityEditor.AssetDatabase.CreateAsset(wallSection, Path.Combine(directory, "newWallSection.asset")); } #endif BuildRSettings settings = BuildRSettings.GetSettings(); wallSection._openingWidthAbs = settings.defaultWindowWidth; wallSection._openingHeightAbs = settings.defaultWindowHeight; wallSection._openingDepth = settings.defaultWindowDepth; return(wallSection); }
private string MaterialFilePath() { BuildRSettings settings = BuildRSettings.GetSettings(); string settingsLocation = UnityEditor.AssetDatabase.GetAssetPath(settings); if (string.IsNullOrEmpty(settingsLocation)) { return(""); } int dirLength = settingsLocation.Length - (settings.name.Length + 6);//+6 for .asset string settingsFolder = settingsLocation.Substring(0, dirLength); string tempTextureFolder = Concat(settingsFolder, MATERIAL_FOLDER_PATH); string dataPath = Application.dataPath; int dataPathLength = dataPath.Length; string projectPath = Application.dataPath.Substring(0, dataPathLength - 6);//cull assets folder reference string fullTempTextureFolder = Concat(projectPath, tempTextureFolder); if (!Directory.Exists(fullTempTextureFolder)) { Directory.CreateDirectory(fullTempTextureFolder); } return(Concat(tempTextureFolder, "buildr_atlas_", name, ".mat")); }
public static BuildRSettings GetSettings() { if (building != null) { return(building.getSettings); } return(BuildRSettings.GetSettings()); }
public static GUIDIconData GenerateGUIDIconData(string guid) { GUIDIconData output = new GUIDIconData(); #if UNITY_EDITOR if (settings == null) { settings = BuildRSettings.GetSettings(); } string settingsLocation = UnityEditor.AssetDatabase.GetAssetPath(settings); if (string.IsNullOrEmpty(settingsLocation)) { return(output); } // string settingsFolder = settingsLocation.Split(new[] { settings.name }, StringSplitOptions.RemoveEmptyEntries)[0]; int dirLength = settingsLocation.Length - (settings.name.Length + 6);//+6 for .asset string settingsFolder = settingsLocation.Substring(0, dirLength); string tempTextureFolder = Concat(settingsFolder, IconFolderPath);//Path.Combine(settingsFolder, IconFolderPath); if (!TEMP_TEXTURE_FOLDER_EXISTS) { string dataPath = Application.dataPath; int dataPathLength = dataPath.Length; string projectPath = Application.dataPath.Substring(0, dataPathLength - 6); //cull assets folder reference string fullTempTextureFolder = Concat(projectPath, tempTextureFolder); //Path.Combine(projectPath, tempTextureFolder); if (!Directory.Exists(fullTempTextureFolder)) { Directory.CreateDirectory(fullTempTextureFolder); } TEMP_TEXTURE_FOLDER_EXISTS = true; } // string textureFilename = Concat(guid, ".jpg"); string tempTexturePath = Concat(tempTextureFolder, guid, ".jpg");//Path.Combine(tempTextureFolder, textureFilename); bool tempTextureFileExists = File.Exists(tempTexturePath); string assetPath = string.IsNullOrEmpty(guid) ? "" : UnityEditor.AssetDatabase.GUIDToAssetPath(guid); output.assetPath = assetPath; output.tempTexturePath = tempTexturePath; output.tempTextureFolder = tempTextureFolder; output.tempTextureFileExists = tempTextureFileExists; #endif return(output); }
public static string GeneratePath(string filename, string foldername) { #if UNITY_EDITOR string basePath = BuildRSettings.GetSettings().newObjectLocation; string folderPath = string.Format("{0}{1}", basePath, foldername); string absFolderPath = string.Format("{0}{1}", Application.dataPath, folderPath); if (!Directory.Exists(absFolderPath)) { Directory.CreateDirectory(absFolderPath); } string adbPath = string.Format("{0}/{1}", "Assets", folderPath); string output = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(Path.Combine(adbPath, filename)); return(output); #else return(""); #endif }
private void UpdatePreviewMesh() { string meshName = string.Format("{0}_Preview_Mesh", name); BuildRMesh pBMesh = new BuildRMesh(meshName); if (_previewMesh == null) { _previewMesh = new Mesh(); } _previewMesh.name = meshName; if (_settings == null) { _settings = BuildRSettings.GetSettings(); } Vector3 left = new Vector3(-_settings.previewGableWidth * 0.5f, -_settings.previewGableHeight * 0.5f, 0); Vector3 right = new Vector3(_settings.previewGableWidth * 0.5f, -_settings.previewGableHeight * 0.5f, 0); GableGenerator.Generate(ref pBMesh, this, left, right, _settings.previewGableHeight, _settings.previewGableThickness, new Vector2()); pBMesh.Build(_previewMesh); }
static void ItemOnGui(string guid, Rect rect) { if (settings == null) { settings = BuildRSettings.GetSettings(); } if (!settings.iconPreviews) { return; } bool defaultFound = settings.defaultIcon != null; Rect squareRect = new Rect(rect.x, rect.y, rect.height, rect.height); float defaultHeight = Mathf.Min(56, rect.height); float defaultWidth = Mathf.Min(44, rect.width, defaultHeight * 0.7857f); float defaultX = rect.x; float defaultY = rect.y; if (rect.height > 56) { defaultX = rect.x + (rect.width - 44) * 0.5f; defaultY = rect.y + (rect.height - 70) * 0.5f; } Rect defaultRect = new Rect(defaultX, defaultY, defaultWidth, defaultHeight); // IconUtil.GUIDIconData iconData = settings.GetCustomIconData(guid); // if(iconData == null) // { // iconData = IconUtil.GenerateGUIDIconData(guid); // settings.AddCustomIconData(guid, iconData); // } string assetPath = AssetDatabase.GUIDToAssetPath(guid); WallSection wallSection = AssetDatabase.LoadAssetAtPath(assetPath, typeof(WallSection)) as WallSection; if (wallSection != null) { Texture2D wallSectionPreview = wallSection.previewTexture; if (wallSectionPreview != null) { GUI.DrawTexture(squareRect, wallSectionPreview); } else if (defaultFound) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } } Facade facade = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Facade)) as Facade; if (facade != null) { Texture2D facadePreview = facade.previewTexture; if (facadePreview != null) { GUI.DrawTexture(squareRect, facadePreview); } else if (defaultFound) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } } Surface surface = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Surface)) as Surface; if (surface != null && surface.previewTexture != null) { if (surface.previewTexture != null) { GUI.DrawTexture(squareRect, surface.previewTexture); } else if (defaultFound) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } } Gable gable = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Gable)) as Gable; if (defaultFound && gable != null) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } RoomStyle roomStyle = AssetDatabase.LoadAssetAtPath(assetPath, typeof(RoomStyle)) as RoomStyle; if (defaultFound && roomStyle != null) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } Portal portal = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Portal)) as Portal; if (defaultFound && portal != null) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } BuildRSettings settingsIcon = AssetDatabase.LoadAssetAtPath(assetPath, typeof(BuildRSettings)) as BuildRSettings; if (defaultFound && settingsIcon != null) { GUI.DrawTexture(defaultRect, settings.defaultIcon); } }