private static void ClearSetting() { DirectoryInfo directoryInfo = new DirectoryInfo(BUILD_PROJECT_SETTING_PATH); if (!directoryInfo.Exists) { directoryInfo.Create(); } AssetDatabase.DeleteAsset(BUILD_PROJECT_SETTING_FILE_PATH); _instance = null; }
private static BuildProjectSetting CreateSettingForce() { DirectoryInfo directoryInfo = new DirectoryInfo(BUILD_PROJECT_SETTING_PATH); if (!directoryInfo.Exists) { directoryInfo.Create(); } BuildProjectSetting setting = CreateInstance <BuildProjectSetting>(); AssetDatabase.CreateAsset(setting, BUILD_PROJECT_SETTING_FILE_PATH); return(setting); }
private static BuildProjectSetting FindBuildProjectSetting() { BuildProjectSetting result = null; // Resources.FindObjectsOfTypeAll查找该类型的所有对象 // 这个函数可以返回加载的Unity物体的任意类型,包含游戏对象、预制体、材质、网格、纹理等等 BuildProjectSetting[] buildProjectSettings = Resources.FindObjectsOfTypeAll <BuildProjectSetting>(); if (buildProjectSettings != null && buildProjectSettings.Length > 0) { result = buildProjectSettings[0]; } if (!result) { string assetPath = Path.Combine(BUILD_PROJECT_SETTING_PATH, BUILD_PROJECT_SETTING_NAME + ".asset"); result = AssetDatabase.LoadAssetAtPath <BuildProjectSetting>(assetPath); } return(result); }