public PlatformInfo FillPlatformInfo(GameObject from) { ModularPlatform console = from.GetComponentInChildren <ModularPlatform>(); PlatformInfo platformInfo = new PlatformInfo() { platformGameObject = from.gameObject, speed = console.GetSpeed(), maxHeight = console.GetMaxHeight(), currentTarget = console.currentTarget, controllable = !console.autoPilot, consolePosition = console.gameObject.transform.position, consoleRotation = console.gameObject.transform.rotation, platformPosition = from.GetComponentInChildren <ModularPlatformUnderCollision>().transform.position }; for (int i = 0; i < console.target.Count; ++i) { platformInfo.waypoints.Add(console.target[i].position); } RemovePlatformExpand[] expands = from.GetComponentsInChildren <RemovePlatformExpand>(); for (int i = 0; i < expands.Length; ++i) { for (int j = 0; j < expands[i].transform.childCount; ++j) { PlatformTopInfo platformTop = new PlatformTopInfo() { serializedTransform = new PlatformTopTransform() { position = expands[i].transform.GetChild(j).transform.position, rotation = expands[i].transform.GetChild(j).transform.rotation }, parent = new PlatformTopTransform() { position = expands[i].transform.position, rotation = expands[i].transform.rotation, } }; platformInfo.platformTops.Add(platformTop); } } return(platformInfo); }