private TintTextureGenerator GetGenerator(GridLayout grid) { TintTextureGenerator generator = FindObjectOfType <TintTextureGenerator>(); if (generator == null) { if (grid != null) { generator = grid.gameObject.AddComponent <TintTextureGenerator>(); } } return(generator); }
public override void BoxErase(GridLayout grid, GameObject layer, BoundsInt position) { Tilemap walls = GetWall(); Tilemap floor = GetFloor(); if (walls != null && floor != null) { foreach (var pos in position.allPositionsWithin) { EraseInternal(pos, floor, walls); } TintTextureGenerator.RefreshTintmap(position); } }
public override void Pick(GridLayout grid, UnityEngine.GameObject brushTarget, BoundsInt position, Vector3Int pivot) { // Do not allow editing palettes if (brushTarget.layer == 31) { return; } TintTextureGenerator generator = GetGenerator(grid); if (generator != null) { m_Color = generator.GetColor(grid as Grid, position.min); } }
public override void Erase(GridLayout grid, UnityEngine.GameObject brushTarget, Vector3Int position) { // Do not allow editing palettes if (brushTarget.layer == 31) { return; } TintTextureGenerator generator = GetGenerator(grid); if (generator != null) { generator.SetColor(grid as Grid, position, Color.white); } }
/// <summary> /// Tints tiles into a given position within the selected layers. /// The TintBrushSmooth overrides this to set the color of the Grid position to tint it. /// </summary> /// <param name="gridLayout">Grid used for layout.</param> /// <param name="brushTarget">Target of the paint operation. By default the currently selected GameObject.</param> /// <param name="position">The coordinates of the cell to paint data to.</param> public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int position) { // Do not allow editing palettes if (brushTarget.layer == 31) { return; } TintTextureGenerator generator = GetGenerator(grid); if (generator != null) { var oldColor = generator.GetColor(grid as Grid, position); var blendColor = oldColor * (1 - m_Blend) + m_Color * m_Blend; generator.SetColor(grid as Grid, position, blendColor); } }
public static void PrepareScene(string prefabPath, Vector3 gridCellSize) { GameObject rig = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath + "/Camera.prefab"); GameObject walls = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath + "/Walls.prefab"); GameObject floor = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath + "/Floor.prefab"); //GameObject hero = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Hero.prefab"); //GameObject gameState = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Game state manager.prefab"); //GameObject canvas = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Canvas stack.prefab"); //GameObject start = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Level Start.prefab"); //GameObject goal = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Level Goal.prefab"); //GameObject swarmSpawner = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Swarm Spawner.prefab"); // Used to tint the overall tilemap and add shadows around walls //GameObject tintTextureGenerator = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefabs/Tint Texture Generator.prefab"); //if (rig != null && walls != null && floor != null && hero != null && gameState != null && canvas != null && start != null && goal != null && swarmSpawner != null) { if (rig != null && walls != null && floor != null) { RenderSettings.ambientLight = Color.white; foreach (var cam in Object.FindObjectsOfType <Camera>()) { Object.DestroyImmediate(cam.gameObject, false); } Grid grid = BrushUtility.GetRootGrid(true); grid.cellSize = gridCellSize; PrefabUtility.InstantiatePrefab(rig); GameObject wallsGo = PrefabUtility.InstantiatePrefab(walls) as GameObject; PrefabUtility.DisconnectPrefabInstance(wallsGo); wallsGo.transform.SetParent(grid.transform); GameObject floorGo = PrefabUtility.InstantiatePrefab(floor) as GameObject; PrefabUtility.DisconnectPrefabInstance(floorGo); floorGo.transform.SetParent(grid.transform); //PrefabUtility.InstantiatePrefab(gameState); //PrefabUtility.InstantiatePrefab(swarmSpawner); //GameObject canvasObject = PrefabUtility.InstantiatePrefab(canvas) as GameObject; //canvasObject.GetComponentInChildren<UIRenderTextureCamera>().UpdateCamera(); //GameObject startGo = PrefabUtility.InstantiatePrefab(start) as GameObject; //startGo.transform.SetParent(grid.transform); //startGo.transform.position = grid.GetCellCenterWorld(new Vector3Int(-6, 1, 0)); //GameObject goalGo = PrefabUtility.InstantiatePrefab(goal) as GameObject; //goalGo.transform.SetParent(grid.transform); //goalGo.transform.position = grid.GetCellCenterWorld(new Vector3Int(5, -2, 0)); //GameObject swarmSpawnerGo = PrefabUtility.InstantiatePrefab(swarmSpawner) as GameObject; //swarmSpawnerGo.transform.SetParent(grid.transform); grid.gameObject.AddComponent <GridInformation>(); //GameObject tintTextureGo = PrefabUtility.InstantiatePrefab(tintTextureGenerator) as GameObject; //tintTextureGo.transform.SetParent(grid.transform); LevelBrush.ResetLevelCache(); TintTextureGenerator.RefreshTintmap(); } else { Debug.LogWarning("Some prefabs for initializing the scene are missing."); } }
private void UndoRedoPerformed() { LevelBrush.ResetLevelCache(); TintTextureGenerator.RefreshTintmap(); }