Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

Commit 3ca8449

Browse files
committed
Add mutable objects, add sample
1 parent e2addab commit 3ca8449

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2230
-99
lines changed

Runtime/MutableObjects.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/MutableObjects/Extensions.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Linq;
2+
using MutableObjects.Generic;
3+
using UnityEngine;
4+
5+
namespace MutableObjects.Extensions
6+
{
7+
public static class MutableObjectExtensions
8+
{
9+
/// <summary>
10+
/// Reset all mutable objects to their inspector state.
11+
/// </summary>
12+
public static void ResetMutatedObjects()
13+
{
14+
var mutableObjects = Resources
15+
.FindObjectsOfTypeAll<MutableObject>()
16+
.OfType<IMutableObject>();
17+
18+
foreach (var mutableObject in mutableObjects)
19+
{
20+
mutableObject.ResetValues();
21+
}
22+
}
23+
}
24+
}

Runtime/MutableObjects/Extensions/MutableObjectExtensions.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/MutableObjects/Float.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using MutableObjects.Generic;
2+
using UnityEngine;
3+
4+
namespace MutableObjects.Float
5+
{
6+
[CreateAssetMenu(fileName = "MutableFloat", menuName = "Mutable Objects/Mutable Float")]
7+
public class MutableFloat : MutableObject
8+
{
9+
[SerializeField]
10+
private float value = default;
11+
12+
public float Value { get; set; }
13+
14+
public override void ResetValues()
15+
{
16+
Value = value;
17+
}
18+
}
19+
}

Runtime/MutableObjects/Float/MutableFloat.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/MutableObjects/Generic.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MutableObjects.Generic
2+
{
3+
public interface IMutableObject
4+
{
5+
/// <summary>
6+
/// Reset values on this mutable object to their original ones.
7+
/// </summary>
8+
void ResetValues();
9+
}
10+
}

Runtime/MutableObjects/Generic/IMutableObject.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)