Skip to content

Commit

Permalink
📦 1.1.1 Release
Browse files Browse the repository at this point in the history
- Fixed an issue with the resources folder referencing
- Corrected a large typo in the asset xD
- Updated the CG banner to the latest art.
  • Loading branch information
JonathanMCarter committed Mar 29, 2023
1 parent 5cede62 commit d80528a
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 137 deletions.
Binary file modified Editor/Art/CarterGamesBanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 98 additions & 53 deletions Editor/Asset Utilities/BuildVersionsEditorUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,51 +80,22 @@ public static Texture2D CarterGamesBanner
return cachedCarterGamesBannerImg;
}
}


/// <summary>
/// Gets the build information asset (or makes one if needed)...
/// </summary>
public static BuildInformation BuildInformation
{
get
{
if (cachedBuildInformation != null) return cachedBuildInformation;
public static BuildInformation BuildInformation =>
CreateSoGetOrAssignCache(ref cachedBuildInformation, DefaultBuildInfoPath,
BuildInfoObjectFilter);

if (HasFile(BuildInfoObjectFilter))
{
cachedBuildInformation = (BuildInformation)GetFile<BuildInformation>(BuildInfoObjectFilter);
return cachedBuildInformation;
}

CreateFile<BuildInformation>(DefaultBuildInfoPath);
cachedBuildInformation = (BuildInformation)GetFile<BuildInformation>(BuildInfoObjectFilter);
cachedBuildInformation.SetBuildDate();
return cachedBuildInformation;
}
}


/// <summary>
/// Gets the build version options asset (or makes one if needed)...
/// </summary>
public static BuildVersionOptions BuildOptions
{
get
{
if (cachedBuildOptions != null) return cachedBuildOptions;

if (HasFile(OptionsTypeFilter))
{
cachedBuildOptions = (BuildVersionOptions)GetFile<BuildVersionOptions>(OptionsTypeFilter);
return cachedBuildOptions;
}

CreateFile<BuildVersionOptions>(DefaultBuildOptionsPath);
cachedBuildOptions = (BuildVersionOptions)GetFile<BuildVersionOptions>(OptionsTypeFilter);
return cachedBuildOptions;
}
}
public static BuildVersionOptions BuildOptions =>
CreateSoGetOrAssignCache(ref cachedBuildOptions, DefaultBuildOptionsPath,
OptionsTypeFilter);


/// <summary>
Expand Down Expand Up @@ -153,33 +124,107 @@ public static bool HasFile(string filter)
}



/// <summary>
/// Creates a file of the type requested...
/// Gets a file via filter.
/// </summary>
/// <param name="path">The path to create the file in (Editor Only)</param>
/// <typeparam name="T">The type the file is</typeparam>
public static void CreateFile<T>(string path)
/// <param name="filter">The filter to search for.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>The found file as an object if found successfully.</returns>
private static object GetFileViaFilter<T>(string filter)
{
var instance = ScriptableObject.CreateInstance(typeof(T));
var asset = AssetDatabase.FindAssets(filter, null);
if (asset == null || asset.Length <= 0) return null;
var path = AssetDatabase.GUIDToAssetPath(asset[0]);
return AssetDatabase.LoadAssetAtPath(path, typeof(T));
}


/// <summary>
/// Gets or assigned the cached value of any type, just saving writing the same lines over and over xD
/// </summary>
/// <param name="cache">The cached value to assign or get.</param>
/// <param name="filter">The filter to use.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>The assigned cache.</returns>
private static T GetOrAssignCache<T>(ref T cache, string filter)
{
if (cache != null) return cache;
cache = (T)GetFileViaFilter<T>(filter);
return cache;
}


/// <summary>
/// Creates a scriptable object if it doesn't exist and then assigns it to its cache.
/// </summary>
/// <param name="cache">The cached value to assign or get.</param>
/// <param name="path">The path to create to if needed.</param>
/// <param name="filter">The filter to use.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>The assigned cache.</returns>
private static T CreateSoGetOrAssignCache<T>(ref T cache, string path, string filter) where T : ScriptableObject
{
if (cache != null) return cache;
cache = (T)GetFileViaFilter<T>(filter);

var currentPath = string.Empty;

foreach (var element in path.Split('/'))
if (cache == null)
{
if (!element.Equals("Assets"))
currentPath += "/" + element;
else
currentPath = element;

if (Directory.Exists(element)) continue;
Directory.CreateDirectory(currentPath);
cache = CreateScriptableObject<T>(path);
}


return cache;
}


/// <summary>
/// Creates a scriptable object of the type entered when called.
/// </summary>
/// <param name="path">The path to create the new asset at.</param>
/// <typeparam name="T">The type to make.</typeparam>
/// <returns>The newly created asset.</returns>
private static T CreateScriptableObject<T>(string path) where T : ScriptableObject
{
var instance = ScriptableObject.CreateInstance(typeof(T));

CreateToDirectory(path);

AssetDatabase.CreateAsset(instance, path);
AssetDatabase.Refresh();

return (T)instance;
}


/// <summary>
/// Creates all the folders to a path if they don't exist already.
/// </summary>
/// <param name="path">The path to create to.</param>
public static void CreateToDirectory(string path)
{
var currentPath = string.Empty;
var split = path.Split('/');

for (var i = 0; i < path.Split('/').Length; i++)
{
var element = path.Split('/')[i];
currentPath += element + "/";

if (i.Equals(split.Length - 1))
{
continue;
}

if (Directory.Exists(currentPath))
{
continue;
}

Directory.CreateDirectory(currentPath);
}
}


/// <summary>
/// Gets the first file of the type requested that isn't the class (Editor Only)
/// </summary>
Expand Down
13 changes: 6 additions & 7 deletions Editor/BuildVersionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void UpdateCachedVersionNumber()
{
var options = BuildVersionsEditorUtil.BuildOptions;

options.LastSystematicVersionNumberSaved = SystematicVersionUpdater.GetVersionNumber(EditorUserBuildSettings.activeBuildTarget, false);
options.LastSemanticVersionNumberSaved = SemanticVersionUpdater.GetVersionNumber(EditorUserBuildSettings.activeBuildTarget, false);
EditorUtility.SetDirty(options);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Expand Down Expand Up @@ -180,14 +180,14 @@ private static void CallUpdaterInterfaces(BuildTarget target)


/// <summary>
/// Calls the sync all the version numbers that use the systematic number...
/// Calls the sync all the version numbers that use the semantic number...
/// </summary>
public static void CallSyncInterfaces()
{
// Stops the sync if the user is not using systematic updating...
if (BuildVersionsEditorUtil.BuildOptions.updateSystematic == AssetUsageType.Disabled)
// Stops the sync if the user is not using semantic updating...
if (BuildVersionsEditorUtil.BuildOptions.updateSemantic == AssetUsageType.Disabled)
{
BvLog.Warning("Update Systematic is disabled! Sync will not run while this setting is disabled.");
BvLog.Warning("Update semantic is disabled! Sync will not run while this setting is disabled.");
return;
}

Expand All @@ -199,7 +199,7 @@ public static void CallSyncInterfaces()
return;
}

var lastSaved = BuildVersionsEditorUtil.BuildOptions.LastSystematicVersionNumberSaved;
var lastSaved = BuildVersionsEditorUtil.BuildOptions.LastSemanticVersionNumberSaved;

foreach (var t in listeners)
t.OnVersionSync(lastSaved.Length > 0 ? lastSaved : Application.version);
Expand All @@ -209,7 +209,6 @@ public static void CallSyncInterfaces()
/// <summary>
/// Calls all build updaters that use dialogue to update
/// </summary>
/// <param name="target"></param>
private static void CallRelevantDialogueBoxes(BuildTarget target)
{
var listeners = BuildVersionsEditorUtil.GetAllInterfacesOfType<IPreBuildDialogue>();
Expand Down
71 changes: 46 additions & 25 deletions Editor/BuildVersionsMenuOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,91 @@ namespace CarterGames.Assets.BuildVersions.Editor
/// </summary>
public static class BuildVersionsMenuOptions
{
[MenuItem("Tools/Build Versions | CG/Edit Info", priority = 0)]
[MenuItem("Tools/Carter Games/Build Versions/Edit Info", priority = 0)]
public static void EditInfo() => Selection.activeObject = BuildVersionsEditorUtil.BuildInformation;

[MenuItem("Tools/Build Versions | CG/Edit Settings", priority = 1)]

[MenuItem("Tools/Carter Games/Build Versions/Edit Settings", priority = 1)]
public static void EditSettings() => SettingsService.OpenProjectSettings("Project/Carter Games/Build Versions");


[MenuItem("Tools/Build Versions | CG/Type/Set To Prototype")]
[MenuItem("Tools/Carter Games/Build Versions/Type/Set To Prototype")]
public static void SetToPrototype() => BuildVersionsManager.SetBuildType("Prototype");

[MenuItem("Tools/Build Versions | CG/Type/Set To Development")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Set To Development")]
public static void SetToDevelopment() => BuildVersionsManager.SetBuildType("Development");

[MenuItem("Tools/Build Versions | CG/Type/Set To Test")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Set To Test")]
public static void SetToTest() => BuildVersionsManager.SetBuildType("Test");

[MenuItem("Tools/Build Versions | CG/Type/Alpha/Set To Pre-Alpha")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Alpha/Set To Pre-Alpha")]
public static void SetToPreAlpha() => BuildVersionsManager.SetBuildType("Pre-Alpha");

[MenuItem("Tools/Build Versions | CG/Type/Alpha/Set To Closed Alpha")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Alpha/Set To Closed Alpha")]
public static void SetToClosedAlpha() => BuildVersionsManager.SetBuildType("Closed Alpha");

[MenuItem("Tools/Build Versions | CG/Type/Alpha/Set To Alpha")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Alpha/Set To Alpha")]
public static void SetToAlpha() => BuildVersionsManager.SetBuildType("Alpha");

[MenuItem("Tools/Build Versions | CG/Type/Alpha/Set To Open Alpha")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Alpha/Set To Open Alpha")]
public static void SetToOpenAlpha() => BuildVersionsManager.SetBuildType("Open Alpha");

[MenuItem("Tools/Build Versions | CG/Type/Beta/Set To Closed Beta")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Beta/Set To Closed Beta")]
public static void SetToClosedBeta() => BuildVersionsManager.SetBuildType("Closed Beta");


[MenuItem("Tools/Build Versions | CG/Type/Beta/Set To Beta")]
[MenuItem("Tools/Carter Games/Build Versions/Type/Beta/Set To Beta")]
public static void SetToBeta() => BuildVersionsManager.SetBuildType("Beta");

[MenuItem("Tools/Build Versions | CG/Type/Beta/Set To Open Beta")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Beta/Set To Open Beta")]
public static void SetToOpenBeta() => BuildVersionsManager.SetBuildType("Open Beta");

[MenuItem("Tools/Build Versions | CG/Type/Release/Set To Release Candidate")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Release/Set To Release Candidate")]
public static void SetToReleaseCandidate() => BuildVersionsManager.SetBuildType("Release Candidate");

[MenuItem("Tools/Build Versions | CG/Type/Release/Set To Release")]

[MenuItem("Tools/Carter Games/Build Versions/Type/Release/Set To Release")]
public static void SetToRelease() => BuildVersionsManager.SetBuildType("Release");

[MenuItem("Tools/Build Versions | CG/Date/Set Date To Today")]

[MenuItem("Tools/Carter Games/Build Versions/Date/Set Date To Today")]
public static void SetBuildDate() => BuildVersionsManager.SetDate();

[MenuItem("Tools/Build Versions | CG/Build Number/Increment Build Number")]

[MenuItem("Tools/Carter Games/Build Versions/Build Number/Increment Build Number")]
public static void IncrementBuild() => BuildVersionsManager.SetBuildNumber();

[MenuItem("Tools/Build Versions | CG/Build Number/Reset Build Number")]

[MenuItem("Tools/Carter Games/Build Versions/Build Number/Reset Build Number")]
public static void ResetBuild() => BuildVersionsManager.SetBuildNumber(1);


[MenuItem("Tools/Build Versions | CG/Version Number/Increment Major")]
public static void IncrementMajor() => SystematicVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget, 0);
[MenuItem("Tools/Carter Games/Build Versions/Version Number/Increment Major")]
public static void IncrementMajor() => SemanticVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget, 0);


[MenuItem("Tools/Carter Games/Build Versions/Version Number/Increment Minor")]
public static void IncrementMinor() => SemanticVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget, 1);

[MenuItem("Tools/Build Versions | CG/Version Number/Increment Minor")]
public static void IncrementMinor() => SystematicVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget, 1);

[MenuItem("Tools/Build Versions | CG/Version Number/Increment Build")]
public static void IncrementVersionBuild() => SystematicVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget);
[MenuItem("Tools/Carter Games/Build Versions/Version Number/Increment Build")]
public static void IncrementVersionBuild() => SemanticVersionUpdater.CallUpdateVersionNumber(EditorUserBuildSettings.activeBuildTarget);

[MenuItem("Tools/Build Versions | CG/Sync/Sync Application Version Number")]

[MenuItem("Tools/Carter Games/Build Versions/Sync/Sync Application Version Number")]
public static void SyncVersionNumber() => BuildVersionsManager.CallSyncInterfaces();


[MenuItem("Tools/Build Versions | CG/Sync/Update Cached Version Number")]
[MenuItem("Tools/Carter Games/Build Versions/Sync/Update Cached Version Number")]
public static void UpdateCachedVersionNumber() => BuildVersionsManager.UpdateCachedVersionNumber();
}
}
4 changes: 2 additions & 2 deletions Editor/Custom Inspectors/BuildVersionsOptionsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ private void OnEnable()

assetStatus = serializedObject.FindProperty("assetStatus");
buildUpdateTime = serializedObject.FindProperty("buildUpdateTime");
updatePlayerSettingsVersion = serializedObject.FindProperty("updateSystematic");
lastBuildNumber = serializedObject.FindProperty("lastSystematicNumber");
updatePlayerSettingsVersion = serializedObject.FindProperty("updatesemantic");
lastBuildNumber = serializedObject.FindProperty("lastsemanticNumber");
androidCodeSetting = serializedObject.FindProperty("androidUpdateBundleCode");

defaultTextColor = GUI.color;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Interfaces/ISyncable.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace CarterGames.Assets.BuildVersions.Editor
{
/// <summary>
/// Implement to sync version numbers (systematic only)...
/// Implement to sync version numbers (semantic only)...
/// </summary>
public interface ISyncable
{
Expand Down
4 changes: 2 additions & 2 deletions Editor/Settings/AssetVersionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public static class AssetVersionData
/// <summary>
/// The version number of the asset...
/// </summary>
public static string VersionNumber => "1.1.0";
public static string VersionNumber => "1.1.1";


/// <summary>
/// The date this release of the asset was submitted for release...
/// </summary>
public static string ReleaseDate => "01/08/2022";
public static string ReleaseDate => "29/03/2023";
}
}
Loading

0 comments on commit d80528a

Please sign in to comment.