Skip to content

Instantly share code, notes, and snippets.

@olegknyazev
Created October 28, 2018 14:38
Show Gist options
  • Save olegknyazev/c6f54b25d0c94dbfe6eb6f55cb49e86d to your computer and use it in GitHub Desktop.
Save olegknyazev/c6f54b25d0c94dbfe6eb6f55cb49e86d to your computer and use it in GitHub Desktop.
About Formatting: Concise and dense but not functional
bool FindMaskOrDie() {
if (_destroyed)
return false;
mask = NearestMask(transform, out _affectedByMask)
?? NearestMask(transform, out _affectedByMask, enabledOnly: false);
if (mask == null) {
_destroyed = true;
DestroyImmediate(this);
return false;
}
return true;
}
static ISoftMask NearestMask(Transform transform, out bool processedByThisMask, bool enabledOnly = true) {
processedByThisMask = true;
var current = transform;
while (true) {
if (!current)
return null;
if (current != transform) { // Masks do not mask themselves
var mask = GetISoftMask(current, shouldBeEnabled: enabledOnly);
if (mask != null)
return mask;
}
if (IsOverridingSortingCanvas(current))
processedByThisMask = false;
current = current.parent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment