generated from techno-dwarf-works/unity-package-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from techno-dwarf-works/feature/refactoring
Version 0.0.57
- Loading branch information
Showing
28 changed files
with
568 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using Better.Commons.EditorAddons.Drawers.Base; | ||
using Better.Commons.Runtime.Comparers; | ||
|
||
namespace Better.Commons.EditorAddons.Comparers | ||
{ | ||
public class CachedSerializedPropertyComparer : BaseComparer<CachedSerializedPropertyComparer, CachedSerializedProperty>, | ||
IEqualityComparer<CachedSerializedProperty> | ||
{ | ||
public bool Equals(CachedSerializedProperty x, CachedSerializedProperty y) | ||
{ | ||
if (ReferenceEquals(x, y)) return true; | ||
if (ReferenceEquals(x, null)) return false; | ||
if (ReferenceEquals(y, null)) return false; | ||
if (x.GetType() != y.GetType()) return false; | ||
return x == y; | ||
} | ||
|
||
public int GetHashCode(CachedSerializedProperty obj) | ||
{ | ||
return obj.GetHashCode(); | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using Better.Commons.EditorAddons.Extensions; | ||
using UnityEditor; | ||
|
||
namespace Better.Commons.EditorAddons.Drawers.Base | ||
{ | ||
public class CachedSerializedProperty : IEquatable<CachedSerializedProperty> | ||
{ | ||
private readonly int _hashCode; | ||
private readonly SerializedProperty _serializedProperty; | ||
|
||
public SerializedProperty SerializedProperty => _serializedProperty; | ||
|
||
public CachedSerializedProperty(SerializedProperty serializedProperty) | ||
{ | ||
_hashCode = serializedProperty.GetHashCode(); | ||
_serializedProperty = serializedProperty; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(_hashCode, _serializedProperty); | ||
} | ||
|
||
public bool IsValid() | ||
{ | ||
try | ||
{ | ||
if (_serializedProperty == null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!_serializedProperty.Verify()) | ||
{ | ||
return false; | ||
} | ||
|
||
if (_serializedProperty.IsDisposed()) | ||
{ | ||
return false; | ||
} | ||
|
||
return _serializedProperty.serializedObject.targetObject != null; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public bool Equals(CachedSerializedProperty other) | ||
{ | ||
if (ReferenceEquals(null, other)) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
return _hashCode == other._hashCode; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != GetType()) return false; | ||
return Equals((CachedSerializedProperty)obj); | ||
} | ||
|
||
public static implicit operator SerializedProperty(CachedSerializedProperty property) | ||
{ | ||
return property.SerializedProperty; | ||
} | ||
|
||
public static explicit operator CachedSerializedProperty(SerializedProperty property) | ||
{ | ||
return new CachedSerializedProperty(property); | ||
} | ||
|
||
public static bool operator ==(CachedSerializedProperty left, CachedSerializedProperty right) | ||
{ | ||
return !ReferenceEquals(left, null) && left.Equals(right); | ||
} | ||
|
||
public static bool operator !=(CachedSerializedProperty left, CachedSerializedProperty right) | ||
{ | ||
return !ReferenceEquals(left, null) && !left.Equals(right); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Better.Commons.EditorAddons.Drawers.Container | ||
{ | ||
public class ContainerPrewarmElement : SubPrewarmElement | ||
{ | ||
private List<SubPrewarmElement> PrewarmChildren { get; } | ||
|
||
public ContainerPrewarmElement() : base() | ||
{ | ||
PrewarmChildren = new List<SubPrewarmElement>(); | ||
} | ||
|
||
public void Add(SubPrewarmElement prewarmElement) | ||
{ | ||
PrewarmChildren.Add(prewarmElement); | ||
base.Add(prewarmElement); | ||
} | ||
|
||
public IEnumerable<SubPrewarmElement> GetByTags(IEnumerable<object> tag) | ||
{ | ||
return PrewarmChildren.Where(x => x.ContainsAnyTags(tag)); | ||
} | ||
|
||
public bool TryGetByTag(object tag, out SubPrewarmElement element) | ||
{ | ||
element = PrewarmChildren.FirstOrDefault(x => x.ContainsTag(tag)); | ||
return element != null; | ||
} | ||
} | ||
} |
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.