Created
October 28, 2018 14:38
-
-
Save olegknyazev/c6f54b25d0c94dbfe6eb6f55cb49e86d to your computer and use it in GitHub Desktop.
About Formatting: Concise and dense but not functional
This file contains hidden or 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
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