Skip to content

Commit

Permalink
V1.0.5 (#75)
Browse files Browse the repository at this point in the history
* Enable Scene based service loading/unloading (#67)
* Moving the Service Framework editor menu items under tools, aligning with the Reality Toolkit for Asset store distribution
* Update script icons to RC standard
* Feature/utilities deprecation (#74)
* Migrating out the single async helper used by the SF
* Remove redirect [skip-ci]

---------

Co-authored-by: realitycollectivebuildbot <[email protected]>
  • Loading branch information
1 parent eb473eb commit 42bbf7b
Show file tree
Hide file tree
Showing 185 changed files with 2,984 additions and 210 deletions.
12 changes: 10 additions & 2 deletions Editor/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Editor/BaseProfileInspector.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Editor.Extensions;
using RealityCollective.Extensions;
using RealityCollective.ServiceFramework.Definitions;
using RealityCollective.ServiceFramework.Editor.Utilities;
using RealityCollective.ServiceFramework.Extensions;
using System;
using UnityEditor;
using UnityEngine;
Expand Down
2 changes: 1 addition & 1 deletion Editor/BaseProfileInspector.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Editor/ConfigurationProperty.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Definitions.Utilities;
using System;
using UnityEditor;

Expand Down
2 changes: 1 addition & 1 deletion Editor/ConfigurationProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Editor/Extensions/BaseProfileInspectorExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Editor.Extensions;
using RealityCollective.Extensions;
using RealityCollective.ServiceFramework.Extensions;
using RealityCollective.ServiceFramework.Definitions;
using System;
using UnityEditor;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Extensions/BaseProfileInspectorExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Editor/Extensions/EditorGUILayoutExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEditor;
using UnityEngine;

namespace RealityCollective.ServiceFramework.Editor.Utilities
{
/// <summary>
/// Extensions for <see cref="EditorGUILayout"/> usage.
/// </summary>
public static class EditorGUILayoutExtensions
{
/// <summary>
/// Draws a foldout but with bold label text.
/// </summary>
/// <param name="foldout">Foldout state.</param>
/// <param name="content">Foldout label content.</param>
/// <param name="toggleOnLabelClick">Should the foldout toggle on label click?</param>
/// <returns>Returns true, if foldout unfolded.</returns>
public static bool FoldoutWithBoldLabel(bool foldout, GUIContent content, bool toggleOnLabelClick = true)
{
GUIStyle defaultStyle = EditorStyles.foldout;
FontStyle previousStyle = defaultStyle.fontStyle;
defaultStyle.fontStyle = FontStyle.Bold;
foldout = EditorGUILayout.Foldout(foldout, content, toggleOnLabelClick);
defaultStyle.fontStyle = previousStyle;

return foldout;
}
}
}
11 changes: 11 additions & 0 deletions Editor/Extensions/EditorGUILayoutExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 159 additions & 0 deletions Editor/Extensions/ScriptableObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.IO;
using UnityEditor;
using UnityEngine;

namespace RealityCollective.ServiceFramework.Editor.Utilities
{
/// <summary>
/// Extensions for <see cref="ScriptableObject"/>s
/// </summary>
public static class ScriptableObjectExtensions
{
/// <summary>
/// Creates, saves, and then optionally selects a new asset for the target <see cref="ScriptableObject"/>.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want to create an asset file for.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
public static T CreateAsset<T>(this T scriptableObject, bool ping = true) where T : ScriptableObject
{
return CreateAsset(scriptableObject, null, ping);
}

/// <summary>
/// Creates, saves, and then opens a new asset for the target <see cref="ScriptableObject"/>.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want to create an asset file for.</param>
/// <param name="path">Optional path for the new asset.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
public static T CreateAsset<T>(this T scriptableObject, string path, bool ping = true) where T : ScriptableObject
{
return CreateAsset(scriptableObject, path, null, ping);
}

/// <summary>
/// Creates, saves, and then opens a new asset for the target <see cref="ScriptableObject"/>.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want to create an asset file for.</param>
/// <param name="path">Optional path for the new asset.</param>
/// <param name="fileName">Optional filename for the new asset.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
/// <param name="unique">Is the new asset unique, or can we make copies?</param>
public static T CreateAsset<T>(this T scriptableObject, string path, string fileName, bool ping, bool unique = true) where T : ScriptableObject
{
var name = string.IsNullOrEmpty(fileName) ? $"{scriptableObject.GetType().Name}" : fileName;

path ??= "Assets";

name = name.Replace(" ", string.Empty);

path = path.Replace(".asset", string.Empty);

if (!string.IsNullOrWhiteSpace(Path.GetExtension(path)))
{
var subtractedPath = path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal));
path = path.Replace(subtractedPath, string.Empty);
}

path = path.Replace($"{Directory.GetParent(Application.dataPath).FullName}{Path.DirectorySeparatorChar}", string.Empty);

if (!Directory.Exists(Path.GetFullPath(path)))
{
Directory.CreateDirectory(Path.GetFullPath(path));
}

path = $"{path}/{name}.asset";

if (unique)
{
AssetDatabase.GenerateUniqueAssetPath(path);
}

if (File.Exists(Path.GetFullPath(path)))
{
return AssetDatabase.LoadAssetAtPath<T>(path);
}

AssetDatabase.CreateAsset(scriptableObject, path);
AssetDatabase.SaveAssets();

if (!EditorApplication.isUpdating)
{
AssetDatabase.Refresh();
}

scriptableObject = AssetDatabase.LoadAssetAtPath<T>(path);

if (ping)
{
EditorApplication.delayCall += () =>
{
EditorUtility.FocusProjectWindow();
EditorGUIUtility.PingObject(scriptableObject);
Selection.activeObject = scriptableObject;
};
}

Debug.Assert(scriptableObject != null);

return scriptableObject;
}

/// <summary>
/// Attempts to find the asset associated to the instance of the <see cref="ScriptableObject"/>, if none is found a new asset is created.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want to create an asset file for.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
public static T GetOrCreateAsset<T>(this T scriptableObject, bool ping = true) where T : ScriptableObject
{
return GetOrCreateAsset(scriptableObject, null, ping);
}

/// <summary>
/// Attempts to find the asset associated to the instance of the <see cref="ScriptableObject"/>, if none is found a new asset is created.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want to create an asset file for.</param>
/// <param name="path">Optional path for the new asset.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
public static T GetOrCreateAsset<T>(this T scriptableObject, string path, bool ping = true) where T : ScriptableObject
{
return GetOrCreateAsset(scriptableObject, path, null, ping);
}

/// <summary>
/// Attempts to find the asset associated to the instance of the <see cref="ScriptableObject"/>, if none is found a new asset is created.
/// </summary>
/// <param name="scriptableObject"><see cref="ScriptableObject"/> you want get or create an asset file for.</param>
/// <param name="path">Optional path for the new asset.</param>
/// <param name="fileName">Optional filename for the new asset.</param>
/// <param name="ping">The new asset should be selected and opened in the inspector.</param>
public static T GetOrCreateAsset<T>(this T scriptableObject, string path, string fileName, bool ping) where T : ScriptableObject
{
return !AssetDatabase.TryGetGUIDAndLocalFileIdentifier(scriptableObject, out var guid, out long _)
? scriptableObject.CreateAsset(path, fileName, ping, false)
: AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
}

/// <summary>
/// Gets all the scriptable object instances in the project.
/// </summary>
/// <typeparam name="T">The Type of <see cref="ScriptableObject"/> you're wanting to find instances of.</typeparam>
/// <returns>An Array of instances for the type.</returns>
public static T[] GetAllInstances<T>() where T : ScriptableObject
{
// FindAssets uses tags check documentation for more info
var guids = AssetDatabase.FindAssets($"t:{typeof(T).Name}");
var instances = new T[guids.Length];

for (int i = 0; i < guids.Length; i++)
{
instances[i] = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guids[i]));
}

return instances;
}
}
}
11 changes: 11 additions & 0 deletions Editor/Extensions/ScriptableObjectExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor/LinkXmlInstaller.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Editor/Packages/AssetsInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Editor.Utilities;
using RealityCollective.Extensions;
using RealityCollective.ServiceFramework.Editor.Utilities;
using RealityCollective.ServiceFramework.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -46,6 +46,7 @@ public struct AssetInstallerEventArgs
/// <param name="destinationPath">The destination path, typically inside the projects "Assets" directory.</param>
/// <param name="regenerateGuids">Should the guids for the copied assets be regenerated?</param>
/// <param name="skipDialog">If set, assets and configuration is installed without prompting the user.</param>
/// <param name="onlyUnityAssets">Filter the assets from the package to ONLY those provided by Unity, the default is ALL files.</param>
/// <returns><c>true</c> if the assets were successfully installed to the project.</returns>
public static bool TryInstallAssets(string sourcePath, string destinationPath, bool regenerateGuids = false, bool skipDialog = false, bool onlyUnityAssets = false)
=> TryInstallAssets(new Dictionary<string, string> { { sourcePath, destinationPath } }, regenerateGuids, skipDialog, onlyUnityAssets);
Expand All @@ -56,6 +57,7 @@ public static bool TryInstallAssets(string sourcePath, string destinationPath, b
/// <param name="installationPaths">The assets paths to be installed. Key is the source path of the assets to be installed. This should typically be from a hidden upm package folder marked with a "~". Value is the destination.</param>
/// <param name="regenerateGuids">Should the guids for the copied assets be regenerated?</param>
/// <param name="skipDialog">If set, assets and configuration is installed without prompting the user.</param>
/// <param name="onlyUnityAssets">Filter the assets from the package to ONLY those provided by Unity, the default is ALL files.</param>
/// <returns><c>true</c> if the assets were successfully installed to the project.</returns>
public static bool TryInstallAssets(Dictionary<string, string> installationPaths, bool regenerateGuids = false, bool skipDialog = false, bool onlyUnityAssets = false)
{
Expand Down
2 changes: 1 addition & 1 deletion Editor/Packages/AssetsInstaller.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor/Packages/IPackageModulesInstaller.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor/Packages/PackageInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Extensions;
using RealityCollective.ServiceFramework.Definitions;
using RealityCollective.ServiceFramework.Extensions;
using RealityCollective.ServiceFramework.Interfaces;
using RealityCollective.ServiceFramework.Services;
using System;
Expand Down
2 changes: 1 addition & 1 deletion Editor/Packages/PackageInstaller.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Editor/Packages/PackageInstallerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace RealityCollective.ServiceFramework.Editor.Packages
/// A package profile defines services and modules that the package has to offer and may be installed
/// to a <see cref="ServiceProvidersProfile"/> to register those services and modules with the service container.
/// </summary>
[CreateAssetMenu(menuName = "Reality Collective/Service Framework/" + nameof(PackageInstallerProfile), fileName = nameof(PackageInstallerProfile), order = (int)CreateProfileMenuItemIndices.Configuration)]
[CreateAssetMenu(menuName = RuntimeServiceFrameworkPreferences.Service_Framework_Editor_Menu_Keyword + "/Packaging/" + nameof(PackageInstallerProfile), fileName = nameof(PackageInstallerProfile), order = (int)CreateProfileMenuItemIndices.Configuration)]
public class PackageInstallerProfile : BaseProfile
{
[SerializeField, Tooltip("The platforms the package can run on.")]
Expand Down
2 changes: 1 addition & 1 deletion Editor/Packages/PackageInstallerProfile.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Editor/Packages/PackageInstallerProfileInspector.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Reality Collective. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using RealityCollective.Definitions.Utilities;
using RealityCollective.Editor.Extensions;
using RealityCollective.Extensions;
using RealityCollective.ServiceFramework.Attributes;
using RealityCollective.ServiceFramework.Definitions;
using RealityCollective.ServiceFramework.Definitions.Utilities;
using RealityCollective.ServiceFramework.Editor.Profiles;
using RealityCollective.ServiceFramework.Editor.PropertyDrawers;
using RealityCollective.ServiceFramework.Editor.Utilities;
using RealityCollective.ServiceFramework.Extensions;
using RealityCollective.ServiceFramework.Services;
using System;
using System.Collections.Generic;
Expand Down
Loading

0 comments on commit 42bbf7b

Please sign in to comment.