mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-23 16:48:23 -05:00
7763f81ede
* Unified all line endings in project to align with .editorconfig; all end-of-line characters have been set to LF and new-lines placed at the end of every file if not present.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UnityAtoms
|
|
{
|
|
public abstract class ScriptableObjectVariableBase<T> : ScriptableObject, IWithValue<T>
|
|
{
|
|
[Multiline]
|
|
public string DeveloperDescription = "";
|
|
|
|
public virtual T Value { get { return value; } set { throw new NotImplementedException(); } }
|
|
|
|
[SerializeField]
|
|
protected T value;
|
|
|
|
protected bool Equals(ScriptableObjectVariableBase<T> other) {
|
|
return EqualityComparer<T>.Default.Equals(value, other.value);
|
|
}
|
|
|
|
public override bool Equals(object obj) {
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
if (ReferenceEquals(this, obj)) return true;
|
|
if (obj.GetType() != this.GetType()) return false;
|
|
return Equals((ScriptableObjectVariableBase<T>) obj);
|
|
}
|
|
|
|
public override int GetHashCode() {
|
|
unchecked {
|
|
return EqualityComparer<T>.Default.GetHashCode(value);
|
|
}
|
|
}
|
|
|
|
public static bool operator ==(ScriptableObjectVariableBase<T> left, ScriptableObjectVariableBase<T> right) { return Equals(left, right); }
|
|
public static bool operator !=(ScriptableObjectVariableBase<T> left, ScriptableObjectVariableBase<T> right) { return !Equals(left, right); }
|
|
}
|
|
}
|