private void SpawnFill(int depth = 0) { if (Argument is Expression || depth < 2) { gameObject.layer = LayerMask.NameToLayer("Pre-render Expression"); var fillType = Argument.Type; if (RenderingOptions.FillMode == FillMode.Head) { if (Argument is Expression) { fillType = ((Expression)Argument).Head.Type; } } else if (RenderingOptions.FillMode == FillMode.Output) { if (fillType is FunctionalType) { fillType = ((FunctionalType)fillType).Output; } } else if (RenderingOptions.FillMode == FillMode.Complete) { // Do nothing, already set } gameObject.GetComponent <Renderer>().material.SetColor("_Color", ColorsByType[fillType]); foreach (Transform childArgumentContainer in gameObject.transform) { ArgumentContainer childArgumentContainerScript = childArgumentContainer.gameObject.GetComponent <ArgumentContainer>(); if (childArgumentContainerScript != null) { childArgumentContainerScript.SpawnFill(depth + 1); } } } }