-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,083 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Source/Core/Editor/UI/ProjectSettings/ComponentSettingsProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using UnityEditor; | ||
|
||
namespace VRBuilder.Editor.UI | ||
{ | ||
/// <summary> | ||
/// Settings provider that groups global settings for scene components in separate sections. | ||
/// </summary> | ||
public class ComponentSettingsProvider : BaseSettingsProvider | ||
{ | ||
private const string Path = "Project/VR Builder/Component Settings"; | ||
|
||
private UnityEditor.Editor editor; | ||
|
||
public ComponentSettingsProvider() : base(Path, SettingsScope.Project) { } | ||
|
||
[SettingsProvider] | ||
public static SettingsProvider Provider() | ||
{ | ||
SettingsProvider provider = new ComponentSettingsProvider(); | ||
return provider; | ||
} | ||
|
||
protected override void InternalDraw(string searchContext) | ||
{ | ||
} | ||
} | ||
} |
File renamed without changes.
80 changes: 80 additions & 0 deletions
80
Source/Core/Editor/UI/ProjectSettings/ComponentSettingsSection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System; | ||
using System.Reflection; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using VRBuilder.Core.Runtime.Utils; | ||
|
||
namespace VRBuilder.Editor.UI | ||
{ | ||
/// <summary> | ||
/// Settings section holding global settings for a specified scene component. | ||
/// </summary> | ||
/// <typeparam name="TObject">The component that can be configured by this section.</typeparam> | ||
/// <typeparam name="TSettings">The scriptable object holding the global settings.</typeparam> | ||
public abstract class ComponentSettingsSection<TObject, TSettings> : IProjectSettingsSection where TObject : UnityEngine.Object where TSettings : ComponentSettings<TObject, TSettings>, new() | ||
{ | ||
/// <inheritdoc/> | ||
public abstract string Title { get; } | ||
|
||
/// <summary> | ||
/// Description of this settings section. Will be displayed below the title, before the settings in the scriptable object. | ||
/// </summary> | ||
public abstract string Description { get; } | ||
|
||
/// <inheritdoc/> | ||
public Type TargetPageProvider => typeof(ComponentSettingsProvider); | ||
|
||
/// <inheritdoc/> | ||
public abstract int Priority { get; } | ||
|
||
private UnityEditor.Editor editor; | ||
private TSettings settings; | ||
|
||
/// <inheritdoc/> | ||
public void OnGUI(string searchContext) | ||
{ | ||
EditorGUILayout.Space(); | ||
GUIStyle labelStyle = BuilderEditorStyles.ApplyPadding(BuilderEditorStyles.Paragraph, 0); | ||
GUILayout.Label(Description, labelStyle); | ||
EditorGUILayout.Space(); | ||
|
||
editor.OnInspectorGUI(); | ||
|
||
if (GUILayout.Button("Apply settings in current scene")) | ||
{ | ||
TObject[] objects = Resources.FindObjectsOfTypeAll<TObject>(); | ||
|
||
foreach (TObject snapZone in objects) | ||
{ | ||
GetSettingsInstance().ApplySettings(snapZone); | ||
} | ||
} | ||
|
||
EditorGUILayout.Space(20f); | ||
} | ||
|
||
public ComponentSettingsSection() | ||
{ | ||
editor = UnityEditor.Editor.CreateEditor(GetSettingsInstance()); | ||
} | ||
|
||
private TSettings GetSettingsInstance() | ||
{ | ||
if (settings != null) | ||
{ | ||
return settings; | ||
} | ||
|
||
Type closedGenericType = typeof(SettingsObject<>).MakeGenericType(typeof(TSettings)); | ||
|
||
PropertyInfo instanceProperty = closedGenericType.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public); | ||
|
||
if (instanceProperty != null) | ||
{ | ||
return instanceProperty.GetValue(null) as TSettings; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Source/Core/Editor/UI/ProjectSettings/ComponentSettingsSection.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.