/// <summary> /// 全リソースをバックグラウンドでダウンロード /// </summary> public void DownloadAll() { CharacterSetting.DownloadAll(); TextureSetting.DownloadAll(); SoundSetting.DownloadAll(); SceneGallerySetting.DownloadAll(); }
//**************************** CSVのロード用 ****************************// /// <summary> /// CSVファイルからロードして初期化 /// </summary> /// <param name="parent">コルーチンをまわすためのMonoBehaviour</param> /// <param name="url">ファイルパス</param> /// <param name="version">シナリオバージョン(-1以下で必ずサーバーからデータを読み直す)</param> /// <returns></returns> public IEnumerator LoadCsvAsync(MonoBehaviour parent, string url, int version) { //起動ファイルの読み込み { AssetFile file = AssetFileManager.GetFileCreateIfMissing(url); if (version < 0) { file.Version = file.CacheVersion + 1; } AssetFileManager.Load(file, this); while (!file.IsLoadEnd) { yield return(0); } SettingData.InitFromCsv(file.Csv, url); file.Unuse(this); } parent.StartCoroutine(ScenarioSetting.LoadCsvAsync(SettingData.ScenarioSettingUrlList)); parent.StartCoroutine(CharacterSetting.LoadCsvAsync(SettingData.CharacterSettingUrlList)); parent.StartCoroutine(TextureSetting.LoadCsvAsync(SettingData.TextureSettingUrlList)); parent.StartCoroutine(SoundSetting.LoadCsvAsync(SettingData.SoundSettingUrlList)); parent.StartCoroutine(DefaultParam.LoadCsvAsync(SettingData.ParamSettingUrlList)); parent.StartCoroutine(LayerSetting.LoadCsvAsync(SettingData.LayerSettingUrlList)); parent.StartCoroutine(SceneGallerySetting.LoadCsvAsync(SettingData.SceneGallerySettingUrlList)); while (!IsLoadEndCsv()) { yield return(0); } }
private void DrawTextureProperties(string filter, TextureSetting textureSetting, System.Action <string> addToPaths, System.Action <string> action) { if (GUILayout.Button("扫描", GUILayout.Width(50))) { _textureSetting = textureSetting; _textureSettingPaths.Clear(); var guids = AssetDatabase.FindAssets(filter); var len = guids.Length; for (var i = 0; i < len; i++) { var path = AssetDatabase.GUIDToAssetPath(guids[i]); if (!InFilterList(path) && InContainList(path) && addToPaths != null) { addToPaths(path); } EditorUtility.DisplayProgressBar("处理中...", path, (float)(i + 1) / len); } EditorUtility.ClearProgressBar(); if (_textureSettingPaths.Count < 1) { _window.ShowNotification(new GUIContent("无需处理")); } } if (_textureSetting == textureSetting && _textureSettingPaths.Count > 0) { GUILayout.Label(_textureSettingPaths.Count.ToString(), EditorStyles.textField, GUILayout.Width(50)); if (GUILayout.Button("全部处理", GUILayout.Width(80))) { var len = _textureSettingPaths.Count; for (var i = 0; i < len; i++) { var path = _textureSettingPaths[i]; if (action != null) { action(path); } EditorUtility.DisplayProgressBar("处理中...", path, (float)(i + 1) / len); } EditorUtility.ClearProgressBar(); _textureSettingPaths.Clear(); } if (GUILayout.Button("X", GUILayout.Width(20))) { _textureSettingPaths.Clear(); _textureSetting = TextureSetting.None; } } }
/// <summary> /// Creates the rainfall-based texture setting preset. /// </summary> /// <returns>The rainfall texture setting.</returns> private TextureSetting[] CreateRainTextureSetting() { TextureSetting[] HeatTextures = new TextureSetting[2]; HeatTextures [0] = new TextureSetting(0.0f, 1.0f, 0.0f, 90.0f, 0.0f, 1.0f, 0.0f, 1.0f, (Texture2D)Resources.Load("Textures/cold")); HeatTextures [1] = new TextureSetting(0.0f, 1.0f, 0.0f, 90.0f, 0.0f, 1.0f, 0.0f, 1.0f, (Texture2D)Resources.Load("Textures/colder")); return(HeatTextures); }
//**************************** CSVのロード用 ****************************// /// <summary> /// CSVファイルからロードして初期化 /// </summary> /// <param name="parent">コルーチンをまわすためのMonoBehaviour</param> /// <param name="url">ファイルパス</param> /// <param name="version">シナリオバージョン(-1以下で必ずサーバーからデータを読み直す)</param> /// <returns></returns> public IEnumerator LoadCsvAsync(MonoBehaviour parent, string url, int version) { //起動ファイルの読み込み { AssetFile file = AssetFileManager.Load(url, version, this); Debug.Log("Boot Scenario Version:" + file.Version); while (!file.IsLoadEnd) { yield return(0); } SettingData.InitFromCsv(file.Csv, url); file.Unuse(this); } importVersion = Version; parent.StartCoroutine(ScenarioSetting.LoadCsvAsync(SettingData.ScenarioSettingUrlList)); parent.StartCoroutine(CharacterSetting.LoadCsvAsync(SettingData.CharacterSettingUrlList)); parent.StartCoroutine(TextureSetting.LoadCsvAsync(SettingData.TextureSettingUrlList)); parent.StartCoroutine(SoundSetting.LoadCsvAsync(SettingData.SoundSettingUrlList)); parent.StartCoroutine(DefaultParam.LoadCsvAsync(SettingData.ParamSettingUrlList)); parent.StartCoroutine(LayerSetting.LoadCsvAsync(SettingData.LayerSettingUrlList)); parent.StartCoroutine(SceneGallerySetting.LoadCsvAsync(SettingData.SceneGallerySettingUrlList)); while (!IsLoadEndCsv()) { yield return(0); } }
/// <summary> /// Checks if the cell's rainfall amount is between the given setting's min/max /// </summary> /// <returns>true if rainfall amount is valid, otherwise false</returns>.</returns> /// <param name="setting">The texture setting to compare against</param> /// <param name="rainfall">The rainfall amount of the current cell</param> private bool isCellRainfallValid(TextureSetting setting, float rainfall) { if (rainfall <= setting.MaxRainfall && rainfall >= setting.MinRainfall) { return(true); } return(false); }
/// <summary> /// Checks if the cell's temperature is between the given setting's min/max /// </summary> /// <returns>true if temperature is valid, otherwise false</returns> /// <param name="setting">The texture setting to compare against</param> /// <param name="temperature">The temperature of the current cell</param> private bool isCellTemperatureValid(TextureSetting setting, float temperature) { if (temperature <= setting.MaxTemperature && temperature >= setting.MinTemperature) { return(true); } return(false); }
/// <summary> /// Checks if the cell's steepness is between the given setting's min/max /// </summary> /// <returns>true if steepness is valid, otherwise false</returns> /// <param name="setting">The texture setting to compare against</param> /// <param name="steepness">The steepness of the current cell</param> private bool isCellSteepnessValid(TextureSetting setting, float steepness) { if (steepness <= setting.MaxSteepness && steepness >= setting.MinSteepness) { return(true); } return(false); }
/// <summary> /// Checks if the cell's height is between the given setting's min/max /// </summary> /// <returns>true if height is valid, otherwise false</returns> /// <param name="setting">The texture setting to compare against</param> /// <param name="height">The height of the current cell</param> /// <param name="initialHeight">The initial height of the current cell before erosion</param> private bool isCellHeightValid(TextureSetting setting, float height, float initialHeight) { if (height >= initialHeight * setting.MinHeightAsAPercentage) { return(true); } return(false); }
public bool equal(TextureSetting t) { bool flag = false; if (this.width == t.width && this.height == t.height && (this.textureData == t.textureData && this.cmt == t.cmt) && (this.cms == t.cms && this.cull_back == t.cull_back && (this.cull_both == t.cull_both && this.cull_front == t.cull_front)) && (this.cull_none == t.cull_none && this.ISALPHA == t.ISALPHA && (this.fromAlpha == t.fromAlpha && this.fromSolid == t.fromSolid) && (int)this.textureMode == (int)t.textureMode)) { flag = true; } return(flag); }
/// <summary> /// 起動時の初期化 /// </summary> /// <param name="rootDirResource">ルートディレクトリのリソース</param> public void BootInit(string rootDirResource) { SettingData.BootInit(rootDirResource); LayerSetting.BootInit(SettingData); ScenarioSetting.BootInit(SettingData); CharacterSetting.BootInit(SettingData); TextureSetting.BootInit(SettingData); SoundSetting.BootInit(SettingData); SceneGallerySetting.BootInit(SettingData); }
/// <summary> /// データをクリア /// </summary> public void Clear() { settingData = new AdvBootSetting(); LayerSetting.Clear(); CharacterSetting.Clear(); TextureSetting.Clear(); SoundSetting.Clear(); ScenarioSetting.Clear(); DefaultParam.Clear(); SceneGallerySetting.Clear(); }
private void SaveSettings() { if (texture == null) { return; } var path = AssetDatabase.GetAssetPath(texture); var textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; if (textureImporter == null) { return; } // ------ TextureSetting ------ textureSetting = new TextureSetting(); textureSetting.readable = textureImporter.isReadable; textureSetting.compression = textureImporter.textureCompression; #if !UNITY_5_5_OR_NEWER textureSetting.format = textureImporter.textureFormat: #endif // ------ PlatformSetting ------ #if UNITY_5_5_OR_NEWER platformSettings = new Dictionary <string, PlatformSetting>(); foreach (var platformName in PlatformNames) { var platformTextureSetting = textureImporter.GetPlatformTextureSettings(platformName); if (platformTextureSetting != null) { var platformSetting = new PlatformSetting(); platformSetting.allowsAlphaSplitting = platformTextureSetting.allowsAlphaSplitting; platformSetting.overridden = platformTextureSetting.overridden; platformSetting.format = platformTextureSetting.format; platformSetting.compressionQuality = platformTextureSetting.compressionQuality; platformSetting.compression = platformTextureSetting.textureCompression; platformSettings.Add(platformName, platformSetting); } } #endif }
/// <summary> /// 起動時の初期化 /// </summary> /// <param name="rootDirResource">ルートディレクトリのリソース</param> public void BootInit(string rootDirResource) { if (importVersion < Version) { Debug.LogError("Version Error! Please Import Scenario Data"); } SettingData.BootInit(rootDirResource); LayerSetting.BootInit(SettingData); CharacterSetting.BootInit(SettingData); TextureSetting.BootInit(SettingData); SoundSetting.BootInit(SettingData); DefaultParam.BootInit(); SceneGallerySetting.BootInit(SettingData); ScenarioSetting.BootInit(SettingData); PageContoroller.Clear(); }
/// <summary> /// 設定データのエクセルシートを読み込む /// </summary> /// <param name="sheetName">シート名</param> /// <param name="grid">シートのStringGridデータ</param> public void ParseFromExcel(string sheetName, StringGrid grid) { importVersion = Version; switch (sheetName) { case SheetNameBoot: SettingData.InitFromStringGrid(grid); break; case SheetNameScenario: ScenarioSetting.InitFromStringGrid(grid); break; case SheetNameCharacter: CharacterSetting.InitFromStringGrid(grid); break; case SheetNameTexture: TextureSetting.InitFromStringGrid(grid); break; case SheetNameSound: SoundSetting.InitFromStringGrid(grid); break; case SheetNameLayer: LayerSetting.InitFromStringGrid(grid); break; case SheetNameParam: DefaultParam.InitFromStringGrid(grid); break; case SheetNameSceneGallery: SceneGallerySetting.InitFromStringGrid(grid); break; default: Debug.LogError(LanguageAdvErrorMsg.LocalizeTextFormat(AdvErrorMsg.NotSettingSheet, sheetName)); break; } }
void SwitchTextureFormat() { switch (PackagePlatform.platformCurrent) { case PackagePlatform.PlatformType.Windows: TextureSetting.ChangeTextureFormatAll((TextureImporterFormat)textureFormatWin); break; case PackagePlatform.PlatformType.IOS: TextureSetting.ChangeTextureFormatAll((TextureImporterFormat)textureFormatIOS); break; case PackagePlatform.PlatformType.Android: TextureSetting.ChangeTextureFormatAll((TextureImporterFormat)textureFormatAnd); break; case PackagePlatform.PlatformType.OSX: TextureSetting.ChangeTextureFormatAll((TextureImporterFormat)textureFormatOSX); break; } }
private void DrawTextureScrollList(TextureSetting textureSetting, System.Action <string> act) { if (_textureSetting == textureSetting && _textureSettingPaths.Count > 0) { _textureSettingScrollPos = GUILayout.BeginScrollView(_textureSettingScrollPos, EditorStyles.helpBox); for (var i = 0; i < _textureSettingPaths.Count; i++) { var path = _textureSettingPaths[i]; GUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.MinHeight(20f)); if (GUILayout.Button(path, EditorStyles.label)) { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(path)); } if (GUILayout.Button("处理", GUILayout.Width(50))) { act?.Invoke(path); _textureSettingPaths.RemoveAt(i); } if (GUILayout.Button("X", GUILayout.Width(20))) { _textureSettingPaths.RemoveAt(i); if (_textureSettingPaths.Count < 1) { _textureSetting = TextureSetting.None; } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } }
public static TextureSetting clone(TextureSetting t) { return(new TextureSetting(t.width, t.height, t.cms, t.cmt, t.textureData, t.cull_back, t.cull_front, t.cull_both, t.textureMode, t.textureHRatio, t.textureWRatio, t.palSize, t.ISALPHA, t.processed)); }
private void DrawTextureMemorySize() { GUILayout.BeginHorizontal(EditorStyles.textField); GUILayout.Label("纹理内存占用"); if (_textureSetting == TextureSetting.MemorySize) { GUILayout.Label(_textureMemorySize.ToString(), EditorStyles.textField, GUILayout.Width(100)); } if (GUILayout.Button("扫描", GUILayout.Width(50))) { _textureSetting = TextureSetting.MemorySize; _textureSizes.Clear(); _textureSettingPaths.Clear(); var guids = AssetDatabase.FindAssets("t:texture"); var len = guids.Length; var size = 0L; for (var i = 0; i < len; i++) { var path = AssetDatabase.GUIDToAssetPath(guids[i]); if (!InFilterList(path) && InContainList(path)) { var tex = AssetDatabase.LoadAssetAtPath <Texture>(path); System.Type type = Assembly.Load("UnityEditor.dll").GetType("UnityEditor.TextureUtil"); MethodInfo methodInfo = type.GetMethod("GetStorageMemorySize", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); //Debug.LogFormat("{0}内存占用:{1}", tex.name, EditorUtility.FormatBytes(Profiler.GetRuntimeMemorySizeLong(tex))); //Debug.LogFormat("{0}硬盘占用:{1}", tex.name, EditorUtility.FormatBytes((int)methodInfo.Invoke(null, new object[] { tex }))); if (tex == null) { _textureSizes.Add(new KeyValuePair <string, string>(path, "null")); } else { var bytes = (int)methodInfo.Invoke(null, new object[] { tex }); size += bytes; _textureSizes.Add(new KeyValuePair <string, string>(path, EditorUtility.FormatBytes(bytes))); } } EditorUtility.DisplayProgressBar("扫描中...", path, (float)(i + 1) / len); } _textureMemorySize = EditorUtility.FormatBytes(size); EditorUtility.ClearProgressBar(); } if (_textureSetting == TextureSetting.MemorySize && _textureSizes.Count > 0) { if (GUILayout.Button("清除", GUILayout.Width(50))) { _textureMemorySize = "0"; _textureSizes.Clear(); _textureSetting = TextureSetting.None; } } GUILayout.EndHorizontal(); if (_textureSizes.Count > 0) { _textureSettingScrollPos = GUILayout.BeginScrollView(_textureSettingScrollPos, EditorStyles.helpBox); for (var i = 0; i < _textureSizes.Count; i++) { var path = _textureSizes[i].Key; GUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.MinHeight(20f)); if (GUILayout.Button(path, EditorStyles.label)) { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(path)); } if (GUILayout.Button(_textureSizes[i].Value.ToString(), GUILayout.Width(80))) { } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } }