/// <summary> /// Generates frames and 3D texture /// </summary> /// <param name="noiseProfile">Noise profile</param> /// <param name="materials">Materials, one for each layer</param> /// <param name="textureAssetFileName">Texture file name</param> /// <param name="showConfirm">Show confirm dialog?</param> public static void GenerateFramesAnd3DTexture(WeatherMakerCloudNoiseProfileGroupScript noiseProfile, Material[] materials, string textureAssetFileName, bool showConfirm = false) { string tempPath = Path.GetTempPath(); tempPath = System.IO.Path.Combine(tempPath, "WeatherMakerNoiseTexture"); string texturesPath = WeatherMakerCloudNoiseGeneratorScript.GenerateFrameTextures(noiseProfile, materials, 0.0f, 0.5f, false); WeatherMakerCloudNoiseGeneratorScript.Generate3DTexture(texturesPath, textureAssetFileName, noiseProfile.FilterMode, noiseProfile.GenerateMips, progress: 0.5f, progressMultiplier: 0.5f); }
public static void Generate3DTexture() { string inputFolder = EditorUtility.OpenFolderPanel("Select input assets folder of images, i.e. myproject/assets/subfolder/images/", string.Empty, string.Empty); if (string.IsNullOrEmpty(inputFolder)) { return; } WeatherMakerCloudNoiseGeneratorScript.Generate3DTexture(inputFolder, "Assets/My3DTexture.asset", FilterMode.Bilinear, true); }
private void OnGUI() { float textureHeight = Mathf.Max(position.height - 80.0f, 180.0f); float fieldWidth = EditorGUIUtility.fieldWidth; EditorGUIUtility.fieldWidth = 800.0f; Rect rect = new Rect(4.0f, textureHeight + 8.0f, EditorGUIUtility.fieldWidth, EditorGUIUtility.singleLineHeight); noiseProfile = EditorGUI.ObjectField(rect, "Cloud Noise Profile", noiseProfile, typeof(WeatherMakerCloudNoiseProfileGroupScript), false) as WeatherMakerCloudNoiseProfileGroupScript; if (noiseProfile != null && noiseProfile.NoiseProfiles != null && noiseProfile.NoiseProfiles.Length <= materials.Length) { for (int i = 0; i < noiseProfile.NoiseProfiles.Length; i++) { float x = 4.0f + (i * textureHeight) + (i * 4.0f); float y = 4.0f; Rect rect2 = new Rect(x, y, textureHeight, textureHeight); //GUI.DrawTexture(rect2, renderTextures[i], ScaleMode.ScaleToFit); EditorGUI.DrawTextureTransparent(rect2, renderTextures[i], ScaleMode.ScaleToFit); } EditorPrefs.SetString("WeatherMakerCloudNoiseGeneratorLastProfile", AssetDatabase.GetAssetPath(noiseProfile)); } rect.y += EditorGUIUtility.singleLineHeight + 4.0f; rect.width = 100.0f; if (GUI.Button(rect, "Browse")) { string file = WeatherMakerCloudNoiseGeneratorScript.PickAssetFile(textureAssetPath); if (!string.IsNullOrEmpty(file)) { textureAssetPath = file; GUI.FocusControl(null); } } rect.xMin = rect.width + 8.0f; rect.width = EditorGUIUtility.fieldWidth - 208.0f; textureAssetPath = EditorGUI.TextField(rect, string.Empty, textureAssetPath); rect.xMin = rect.xMin + rect.width + 4.0f; rect.width = 100.0f; if (GUI.Button(rect, "Export")) { WeatherMakerCloudNoiseGeneratorScript.GenerateFramesAnd3DTexture(noiseProfile, materials, textureAssetPath); Repaint(); } EditorGUIUtility.fieldWidth = fieldWidth; rect.y += EditorGUIUtility.singleLineHeight + 4.0f; rect.xMin = 4.0f; rect.width = 200.0f; float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 68.0f; animated = EditorGUI.Toggle(rect, "Animated", animated); EditorGUIUtility.labelWidth = labelWidth; }