Skip to content

Commit

Permalink
Update ValidateHierarchy.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMeesters committed Dec 12, 2019
1 parent f2f7f30 commit f440aec
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions Assets/Plugins/Lowscope/ValidateHierarchy/ValidateHierarchy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
*
Copyright notice - Licence: MIT. https://opensource.org/licenses/MIT
Provided by Alex Meesters. www.alexmeesters.nl. Used within low-scope.com products.
Source: https://github.com/AlexMeesters/UnityValidateHierarchy
Expand All @@ -11,7 +11,6 @@ Provided by Alex Meesters. www.alexmeesters.nl. Used within low-scope.com produc
Please note that the OnValidate method must be public. Else it won't work.
Cheers! All the defines are added to prevent any building errors.
*/


Expand Down Expand Up @@ -83,13 +82,11 @@ public static void Remove(MonoBehaviour monoBehaviour)

if (validateableMonobehaviours.ContainsKey(monoBehaviour.transform.root))
{
if (validateableMonobehaviours.Count == 1)
{
validateableMonobehaviours.Clear();
}
else
validateableMonobehaviours[monoBehaviour.transform.root].Remove(monoBehaviour);

if (validateableMonobehaviours[monoBehaviour.transform.root].Count == 0)
{
validateableMonobehaviours[monoBehaviour.transform.root].Remove(monoBehaviour);
validateableMonobehaviours.Remove(monoBehaviour.transform.root);
}
}
#endif
Expand All @@ -113,15 +110,10 @@ public static void Add(MonoBehaviour monoBehaviour)

if (!validateableMonobehaviours.ContainsKey(monoBehaviour.transform.root))
{
validateableMonobehaviours.Add(monoBehaviour.transform.root, new HashSet<MonoBehaviour>() { monoBehaviour });
}
else
{
if (!validateableMonobehaviours[monoBehaviour.transform.root].Contains(monoBehaviour))
{
validateableMonobehaviours[monoBehaviour.transform.root].Add(monoBehaviour);
}
validateableMonobehaviours.Add(monoBehaviour.transform.root, new HashSet<MonoBehaviour>());
}

validateableMonobehaviours[monoBehaviour.transform.root].Add(monoBehaviour);
#endif
}
#if UNITY_EDITOR
Expand Down Expand Up @@ -185,16 +177,15 @@ private static void CallValidation(Transform target)
if (item != null)
{
MethodInfo tMethod = item.GetType().GetMethod("OnValidate");

if (tMethod != null)
{
tMethod.Invoke(item, null);
break;
}
}
}
}
}
#endif
}

}

0 comments on commit f440aec

Please sign in to comment.