Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c02fb5f

Browse files
Core Code Updated
- Updated core codebase with some new stuff and neatened them up a little xD
1 parent 5b595b0 commit c02fb5f

File tree

9 files changed

+433
-103
lines changed

9 files changed

+433
-103
lines changed

Core/Art/Scene Group Icon.png

5.74 KB
Loading

Core/Editor/SceneGroupEditor.cs

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,21 @@
99
using UnityEditor;
1010
using UnityEngine;
1111

12-
namespace MultiScene.Editor
12+
namespace MultiScene.Core.Editor
1313
{
1414
[CustomEditor(typeof(SceneGroup))]
1515
public class SceneGroupEditor : UnityEditor.Editor
1616
{
17-
public static Color Green => new Color32(72, 222, 55, 255);
18-
public static Color Yellow => new Color32(245, 234, 56, 255);
19-
public static Color Orange => new Color32(255, 170, 134, 255);
20-
public static Color Red => new Color32(255, 150, 157, 255);
21-
public static Color Blue => new Color32(151, 196, 255, 255);
22-
public static Color Purple => new Color32(196, 151, 255, 255);
23-
public static Color Pink => new Color32(255, 151, 242, 255);
24-
public static Color LightGrey => new Color32(199, 199, 199, 255);
25-
public static Color DarkGrey => new Color32(88, 88, 88, 255);
26-
public static Color White => Color.white;
27-
public static Color Black => Color.black;
28-
17+
private static Color Green => new Color32(72, 222, 55, 255);
18+
private static Color Yellow => new Color32(245, 234, 56, 255);
19+
private static Color Red => new Color32(255, 150, 157, 255);
20+
2921

3022
private SerializedProperty scenes;
31-
private Color defaultBGCol;
32-
private Color defaultGUICol;
23+
private static Color defaultBGCol;
24+
private static Color defaultGUICol;
3325

26+
3427
private void OnEnable()
3528
{
3629
scenes = serializedObject.FindProperty("scenes");
@@ -43,15 +36,12 @@ public override void OnInspectorGUI()
4336
{
4437
serializedObject.Update();
4538

46-
HorizontalCentered(() =>
47-
{
48-
BoldCompact(" Scene Group ");
49-
});
39+
// Renders the title for the group...
40+
HorizontalCentered(RenderSceneGroupTitle);
5041

42+
// Shows the base field button if there are no entries in the scene group...
5143
if (scenes == null || scenes.arraySize <= 0)
52-
{
5344
GreenButton("Add Base Scene", CallAddBaseField);
54-
}
5545

5646
if (scenes.arraySize > 0)
5747
{
@@ -60,22 +50,39 @@ public override void OnInspectorGUI()
6050
if (scenes.arraySize > 1)
6151
RenderAdditiveSceneFields();
6252
else
63-
YellowButton("Add Scene", CallAddNewAdditiveScene);
53+
YellowButton("Add Additive Scene", CallAddNewAdditiveScene);
54+
55+
GUILayout.Space(25f);
56+
RedButton("Reset", CallResetGroup);
6457
}
6558

59+
// Applies changes if changes have been made...
60+
if (!serializedObject.hasModifiedProperties) return;
6661
serializedObject.ApplyModifiedProperties();
67-
68-
// Un-comment for debugging...
69-
//base.OnInspectorGUI();
7062
}
7163

7264

65+
/// <summary>
66+
/// Adds the base scene to the editor
67+
/// </summary>
7368
private void CallAddBaseField()
7469
{
7570
scenes.InsertArrayElementAtIndex(0);
7671
}
72+
73+
74+
/// <summary>
75+
/// Renders the title section of the editor...
76+
/// </summary>
77+
private void RenderSceneGroupTitle()
78+
{
79+
BoldCompact(" Scene Group ");
80+
}
7781

7882

83+
/// <summary>
84+
/// Renders the base scene grouping...
85+
/// </summary>
7986
private void RenderBaseSceneField()
8087
{
8188
GUI.backgroundColor = Green;
@@ -87,6 +94,9 @@ private void RenderBaseSceneField()
8794
}
8895

8996

97+
/// <summary>
98+
/// Renders the additive scenes into a grouping...
99+
/// </summary>
90100
private void RenderAdditiveSceneFields()
91101
{
92102
GUI.backgroundColor = Yellow;
@@ -98,33 +108,56 @@ private void RenderAdditiveSceneFields()
98108
{
99109
Horizontal(() =>
100110
{
111+
GUI.backgroundColor = Yellow;
112+
101113
EditorGUILayout.PropertyField(scenes.GetArrayElementAtIndex(i), GUIContent.none);
102114

103115
GreenButton("+", () => CallAddNewAdditiveScene(i));
104116
RedButton("-", () => CallRemoveElementAtIndex(i));
117+
118+
GUI.backgroundColor = defaultBGCol;
105119
});
106120
}
107121

108122
GUI.backgroundColor = defaultBGCol;
109123
}
110124

111-
125+
126+
/// <summary>
127+
/// Removed the element at the index entered...
128+
/// </summary>
129+
/// <param name="i">The element to edit</param>
112130
private void CallRemoveElementAtIndex(int i)
113131
{
114132
scenes.DeleteArrayElementAtIndex(i);
115133
}
116134

135+
/// <summary>
136+
/// Adds a new element to the scenes list that is blank at the element entered.
137+
/// </summary>
138+
/// <param name="i">The element to edit</param>
117139
private void CallAddNewAdditiveScene(int i)
118140
{
119141
scenes.InsertArrayElementAtIndex(i);
120142
scenes.GetArrayElementAtIndex(i + 1).stringValue = string.Empty;
121143
}
122144

145+
/// <summary>
146+
/// Adds a new element to the scenes list that is blank.
147+
/// </summary>
123148
private void CallAddNewAdditiveScene()
124149
{
125150
scenes.InsertArrayElementAtIndex(scenes.arraySize - 1);
126151
scenes.GetArrayElementAtIndex(scenes.arraySize - 1).stringValue = string.Empty;
127152
}
153+
154+
/// <summary>
155+
/// Resets the scenes list to a new list.
156+
/// </summary>
157+
private void CallResetGroup()
158+
{
159+
scenes.ClearArray();
160+
}
128161

129162
/// <summary>
130163
/// Shows a compact button where the label controls the size of the button.
@@ -145,11 +178,10 @@ private static bool CompactButton(string label)
145178
/// <param name="options">GUILayoutOption[] | Layout options.</param>
146179
private static void GreenButton(string label, Action callback, params GUILayoutOption[] options)
147180
{
148-
var _default = GUI.backgroundColor;
149181
GUI.backgroundColor = Green;
150182
if (GUILayout.Button(label, options))
151183
callback();
152-
GUI.backgroundColor = _default;
184+
GUI.backgroundColor = defaultBGCol;
153185
}
154186

155187

@@ -161,11 +193,10 @@ private static void GreenButton(string label, Action callback, params GUILayoutO
161193
/// <param name="options">GUILayoutOption[] | Layout options.</param>
162194
private static void YellowButton(string label, Action callback, params GUILayoutOption[] options)
163195
{
164-
var _default = GUI.backgroundColor;
165196
GUI.backgroundColor = Yellow;
166197
if (GUILayout.Button(label, options))
167198
callback();
168-
GUI.backgroundColor = _default;
199+
GUI.backgroundColor = defaultBGCol;
169200
}
170201

171202

@@ -175,13 +206,12 @@ private static void YellowButton(string label, Action callback, params GUILayout
175206
/// <param name="label">String | Label for the button.</param>
176207
/// <param name="callback">Action | The actions to perform on button press.</param>
177208
/// <param name="options">GUILayoutOption[] | Layout options.</param>
178-
public static void RedButton(string label, Action callback, params GUILayoutOption[] options)
209+
private static void RedButton(string label, Action callback, params GUILayoutOption[] options)
179210
{
180-
var _default = GUI.backgroundColor;
181211
GUI.backgroundColor = Red;
182212
if (GUILayout.Button(label, options))
183213
callback();
184-
GUI.backgroundColor = _default;
214+
GUI.backgroundColor = defaultBGCol;
185215
}
186216

187217
/// <summary>
@@ -221,7 +251,7 @@ private static float TextWidth(string text)
221251
/// </summary>
222252
/// <param name="blockElements">Action | Stuff to display</param>
223253
/// <remarks>Actions can be () => {} or a method.</remarks>
224-
public static void Horizontal(Action blockElements)
254+
private static void Horizontal(Action blockElements)
225255
{
226256
EditorGUILayout.BeginHorizontal();
227257
blockElements();
@@ -234,7 +264,7 @@ public static void Horizontal(Action blockElements)
234264
/// </summary>
235265
/// <param name="blockElements">Action | Stuff to display</param>
236266
/// <remarks>Actions can be () => {} or a method.</remarks>
237-
public static void HorizontalCentered(Action blockElements)
267+
private static void HorizontalCentered(Action blockElements)
238268
{
239269
EditorGUILayout.BeginHorizontal();
240270
GUILayout.FlexibleSpace();

Core/Scripts/BaseMultiSceneLoader.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*
3+
* Multi-Scene Workflow
4+
*
5+
* Base Multi-Scene Loader
6+
* A base class that you can extend to load scenes in a variety of ways.
7+
*
8+
* Written by:
9+
* Jonathan Carter
10+
*
11+
* Last Updated: 05/11/2021 (d/m/y)
12+
*
13+
*/
14+
15+
using UnityEngine;
16+
17+
namespace MultiScene.Core
18+
{
19+
public class BaseMultiSceneLoader : MonoBehaviour
20+
{
21+
/// <summary>
22+
/// The scene group to load...
23+
/// </summary>
24+
[SerializeField] protected SceneGroup loadGroup;
25+
26+
/// <summary>
27+
/// Loads a scene group.
28+
/// </summary>
29+
public virtual void LoadSceneGroup()
30+
{
31+
SceneElly.GetComponentFromAllScenes<MultiSceneManager>().LoadScenes(loadGroup);
32+
}
33+
}
34+
}

Core/Scripts/Interfaces/IMultiSceneAwake.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
// ----------------------------------------------------------------------------
2-
// IMultiSceneAwake.cs
3-
//
4-
// Author: Jonathan Carter (A.K.A. J)
5-
// Date: 06/09/2021
6-
// ----------------------------------------------------------------------------
1+
/*
2+
*
3+
* Multi-Scene Workflow
4+
*
5+
* Multi-Scene Awake Interface
6+
* A interface to implement when you want logic to run first once a scene group has loaded via the multi-scene manager.
7+
*
8+
* Written by:
9+
* Jonathan Carter
10+
*
11+
* Last Updated: 05/11/2021 (d/m/y)
12+
*
13+
*/
714

8-
namespace MultiScene
15+
namespace MultiScene.Core
916
{
1017
public interface IMultiSceneAwake
1118
{

Core/Scripts/Interfaces/IMultiSceneEnable.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
namespace MultiScene
1+
/*
2+
*
3+
* Multi-Scene Workflow
4+
*
5+
* Multi-Scene Enable Interface
6+
* A interface to implement when you want logic to run second once a scene group has loaded via the multi-scene manager.
7+
*
8+
* Written by:
9+
* Jonathan Carter
10+
*
11+
* Last Updated: 05/11/2021 (d/m/y)
12+
*
13+
*/
14+
15+
namespace MultiScene.Core
216
{
317
public interface IMultiSceneEnable
418
{

Core/Scripts/Interfaces/IMultiSceneStart.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
// ----------------------------------------------------------------------------
2-
// IMultiSceneStart.cs
3-
//
4-
// Author: Jonathan Carter (A.K.A. J)
5-
// Date: 14/09/2021
6-
// ----------------------------------------------------------------------------
1+
/*
2+
*
3+
* Multi-Scene Workflow
4+
*
5+
* Multi-Scene Start Interface
6+
* A interface to implement when you want logic to run last but before the post load event once a scene group has loaded via the multi-scene manager.
7+
*
8+
* Written by:
9+
* Jonathan Carter
10+
*
11+
* Last Updated: 05/11/2021 (d/m/y)
12+
*
13+
*/
714

8-
namespace MultiScene
15+
namespace MultiScene.Core
916
{
1017
public interface IMultiSceneStart
1118
{

0 commit comments

Comments
 (0)