private static VisGroup ReadVisGroup(Stream stream) { var visGroup = new VisGroup(); visGroup.Name = stream.ReadLengthPrefixedString(); visGroup.ID = stream.ReadInt(); visGroup.Color = ReadColor(stream); visGroup.IsVisible = stream.ReadBytes(1)[0] != 0; return(visGroup); }
void OccludeCheck() { //get distance and direction Vector3 heading = cachedTargetPos - cachedCameraPos; searchDistance = heading.magnitude; Vector3 dirToCursor = heading / searchDistance; Ray ray = new Ray(cachedCameraPos, dirToCursor); RaycastHit hit; //Racyast. Make sure cursor is actually behind visgroup to fire, otherwsise it should stay visible. visGroupFound = Physics.Raycast(ray, out hit, searchDistance, environmentLayerMask); if (visGroupFound) { curDetVisG = hit.transform.GetComponentInParent <VisGroup>(); if (curDetVisG != curHidVisG) { if (curHidVisG) { curHidVisG.SetVis(true, VisGroupTransitionType.Partial); } curDetVisG.SetVis(false, VisGroupTransitionType.Partial); curHidVisG = curDetVisG; } } else { if (curHidVisG) { curHidVisG.SetVis(true, VisGroupTransitionType.Partial); curHidVisG = null; } } //Collect what is currently detected. }