public override void HandleAOI(BaseAOIFinder finder, bool _inRange) { }
/// <summary> /// Add uConstruct demo into the scene. /// </summary> public static void GX_ApplyDemoToSelectedPlayer() { #if UNITY_EDITOR GameObject player = Selection.activeGameObject; if (player == null) { Debug.LogError("No player is chosen, ABORT."); return; } else { try { GameObject demoPlayerPrefab = Resources.Load <GameObject>("Players/DemoPlayer"); if (demoPlayerPrefab != null) { BuildingPlacer placer = player.GetComponent <BuildingPlacer>(); BaseAOIFinder finder = player.GetComponent <BaseAOIFinder>(); BuildingPlacer demoPlacer = demoPlayerPrefab.GetComponent <BuildingPlacer>(); if (demoPlacer == null) { Debug.LogError("Cant find building placer on CubesDemo player, Buildings cannot be automatically assigned"); } if (placer == null) { placer = player.AddComponent <BuildingPlacer>(); } if (finder == null) { finder = player.AddComponent <BaseAOIFinder>(); } if (demoPlacer != null) { placer.buildings = demoPlacer.buildings; placer.playerCamera = player.GetComponentInChildren <Camera>(); } } else { Debug.LogError("Cant find demo player on CubesDemo, Buildings cannot be automatically assigned"); } } catch (Exception) { Debug.LogError("Applying demo scripts failed."); } } Terrain[] terrains = Terrain.activeTerrains; Terrain terrain; BaseSocket socket; for (int i = 0; i < terrains.Length; i++) { terrain = terrains[i]; if (terrain.GetComponent <BaseSocket>() == null) { socket = terrain.gameObject.AddComponent <BaseSocket>(); socket.receiveType = (BuildingType)Enum.Parse(typeof(BuildingType), "Foundation", true); socket.placingType = PlacingRestrictionType.FreelyBased; socket.usePhysics = false; } } if (GameObject.FindObjectOfType <DemoUI>() == null) { GameObject canvas = Resources.Load <GameObject>("Canvas"); var canvasGO = GameObject.Instantiate(canvas); canvasGO.name = canvas.name; // remove the "Clone" thingy from the name } #endif }