public Form1() { InitializeComponent(); tileset = new Tileset(); TilePalette.Update(tileset); MapEditor.Selected = TilePalette.Selected; MapEditor.CreateMap(tileset); }
public MapEditor() { InitializeComponent(); Tileset.InitiateTileset(); TilePalette.Update(); MapView.Selected = TilePalette.Selected; MapView.CreateMap(); NewMap = new NewMapForm(this); }
private void OnEnable() { // Get Target m_target = (TilePalette)target; // Find the serialized properties m_gridOffset = serializedObject.FindProperty("gridOffset"); m_atlasTexture = serializedObject.FindProperty("atlasTexture"); m_extractNumber = serializedObject.FindProperty("extractNumber"); }
bool IsValid(Vector2 direction) { Vector2 futurePos = _cameraPostition + (direction / EngineSettings.TileSize); CharacterActiveTileX = (int)((DisplayOutputSettings.CenterScreenTileOffsetX + 0.5 + (int)futurePos.X - futurePos.X) * EngineSettings.TileSize); CharacterActiveTileY = (int)((DisplayOutputSettings.CenterScreenTileOffsetY + 0.5 + (int)futurePos.Y - futurePos.Y) * EngineSettings.TileSize); tx = (int)(futurePos.X + DisplayOutputSettings.CenterScreenTileOffsetX); ty = (int)(futurePos.Y + DisplayOutputSettings.CenterScreenTileOffsetY + 1); return(TilePalette.IsWalkable(tx, ty)); }
public virtual void Do() { foreach (Tilemap tilemap in tilemapsParent.GetComponentsInChildren <Tilemap>()) { if (tilemap.GetTile(GridBrush.activeTile.transform.GetColumn(3).ToVec3Int()) != null) { TilePalette.SelectTarget(tilemap.gameObject); return; } } }
List <Vector2> FindPath(Vector2 From) { Node startNode = InitPF(From); while (OpenList.Count != 0) { Node current = FindLowestF(OpenList); if (current.position == _goal) { //Return goal PathNode = current; return(ExtractPath()); } OpenList.Remove(current); ClosedList.Add(current.position); Visited[(int)current.position.X, (int)current.position.Y] = true; for (int X = -1; X <= 1; X++) { for (int Y = -1; Y <= 1; Y++) { if (X != 0 || Y != 0) { Vector2 newPos = new Vector2(current.position.X + X, current.position.Y + Y); Vector2 correctedNewPos = WorldHelp.CorrectWorldOverflow(newPos); if (Visited[(int)correctedNewPos.X, (int)correctedNewPos.Y]) { continue; } else if (OpenList.Any(a => a.position == correctedNewPos)) { continue; } else if (TilePalette.IsTileSailable((int)correctedNewPos.X, (int)correctedNewPos.Y, _elementSize)) { Node newNode = new Node() { parent = current, position = correctedNewPos, G = current.G + ((X == 0 || Y == 0) ? 1 : Sqrt2) }; OpenList.Add(newNode); } } } } } return(new List <Vector2>()); }
// Start is called before the first frame update void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; } tilePalette = new TilePalette(mapTexture, 1); BuildInitialTexture(); gameObject.SetActive(false); }
void LoadBMP( string _path ) { m_openImageName = "<Untitled>"; // Load corresponding config first as it have information on how the image should be loaded m_currentImageConfig = new PalettizedImageConfig( _path + ".config" ); m_haveLoadedImage = true; m_currentImageData = PalettizedImage.LoadImage( _path, m_currentImageConfig ); if( m_currentImageData != null ) { // m_currentImageConfig.SetImage( m_currentImageData ); // m_currentFramesString = m_currentImageConfig.GetNumFrames().ToString(); m_currentFrameTimesString = new Dictionary<int, string>(); int iFrame; for( iFrame=0; iFrame<m_currentImageConfig.GetNumFrames(); iFrame++ ) { m_currentFrameTimesString[ iFrame ] = m_currentImageConfig.GetFrameTime( iFrame ).ToString(); } // m_openImageName = System.IO.Path.GetFileNameWithoutExtension( _path ); m_tileBankWindowRect = new Rect( m_projectWindowWidth + (m_windowPadding*2.0f), m_windowTop, m_currentImageData.m_width*2.0f+10.0f, m_currentImageData.m_height*2.0f+10.0f+15.0f ); m_imageSettingsRect = new Rect( m_tileBankWindowRect.x + m_tileBankWindowRect.width + m_windowPadding, m_tileBankWindowRect.y, 200.0f, 200.0f ); m_paletteRemapRect = new Rect( m_imageSettingsRect.x + m_imageSettingsRect.width + m_windowPadding, m_imageSettingsRect.y, 100.0f, 15.0f + (16.0f * 30.0f) ); // // m_planarImage = new PlanarImage( m_currentImageData); bool OptimizedTilebank = (m_currentImageConfig.m_importAsSprite == false); // If we import the image as a sprite we should not optimize the tile bank m_tileBank = new TileBank( m_currentImageData, OptimizedTilebank ); m_tileMap = new TileMap( m_tileBank, m_currentImageData ); m_tilePalette = new TilePalette( m_currentImageData ); // int w, h; w = m_currentImageData.m_width; h = m_currentImageData.m_height; // m_imageTexture = new Texture2D( w, h, TextureFormat.ARGB32, false ); m_imageTexture.filterMode = FilterMode.Point; // int x, y; for( y=0; y<h; y++ ) { for( x=0; x<w; x++ ) { int ii = ((h-1-y)*w)+x; int ic = m_currentImageData.m_image[ ii ]; Color col = m_currentImageData.m_palette[ ic ]; m_imageTexture.SetPixel( x, y, col ); } } // m_imageTexture.Apply(); } }
// void ExportAll() { // string outFileName = EditorUtility.SaveFilePanel( "Select folder to export to", m_lastExportDirectory, "filenameignored", "bin" ); // m_lastExportDirectory = System.IO.Path.GetDirectoryName( outFileName ); SaveLastExportDirectory(); m_project.Export( m_lastExportDirectory ); // // Export all images // string[] imageFiles = m_project.m_imageFiles; foreach( string imageFile in imageFiles ) { Debug.Log( "Exporting file '" + imageFile + "'" ); string outFileNameNoExt = System.IO.Path.GetFileNameWithoutExtension( imageFile ).ToLower(); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar + outFileNameNoExt; // PalettizedImageConfig imageConfig = new PalettizedImageConfig( imageFile + ".config" ); PalettizedImage imageData = PalettizedImage.LoadImage( imageFile, imageConfig ); // if( imageData != null ) { // imageConfig.SetImage( imageData ); // Convert to tile banks / planar images // PlanarImage planarImage = new PlanarImage( imageData); TileBank tileBank = new TileBank( imageData, (imageConfig.m_importAsSprite==false) ); TilePalette tilePalette = new TilePalette( imageData ); // Export it if( imageConfig.m_importAsSprite ) { Sprite sprite = new Sprite( imageConfig ); string alternativeAmigaSpriteName; if( imageConfig.m_importAsBSprite ) { AmigaSprite amigaSprite = new AmigaSprite( imageData, imageConfig); alternativeAmigaSpriteName = "_sprite_bank_amiga_b_hw.bin"; amigaSprite.Export( outBaseName + alternativeAmigaSpriteName ); } else { AmigaBob amigaBob = new AmigaBob( imageData, imageConfig); alternativeAmigaSpriteName = "_sprite_bank_amiga_a_bob.bin"; amigaBob.Export( outBaseName + alternativeAmigaSpriteName ); } tileBank.ExportMegaDrive( outBaseName + "_sprite_bank.bin" ); tilePalette.Export( outBaseName + "_palette.bin" ); sprite.Export( outBaseName + "_sprite.bin" ); } else { TileMap tileMap = new TileMap( tileBank, imageData ); tileBank.ExportMegaDrive( outBaseName + "_bank.bin" ); tileBank.ExportAmiga( outBaseName + "_bank_amiga.bin" ); tileMap.Export( outBaseName + "_map.bin" ); tilePalette.Export( outBaseName + "_palette.bin" ); } } } // // Export all maps // string[] mapFiles = m_project.m_mapFiles; foreach( string mapFile in mapFiles ) { Debug.Log( "Exporting map '" + mapFile + "'" ); string outFileNameNoExt = System.IO.Path.GetFileNameWithoutExtension( mapFile ).ToLower(); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar + outFileNameNoExt; // TileMap tileMap = TileMap.LoadJson( mapFile ); CollisionMap collisionmap = new CollisionMap( tileMap ); tileMap.Export( outBaseName + "_map.bin" ); collisionmap.Export( outBaseName + "_collisionmap.bin" ); } // // Export all game objects // foreach( string goFile in m_project.m_gameObjectCollectionFiles ) { Debug.Log( "Exporting game object '" + goFile + "'" ); string outFileNameNoExt = m_project.GetOutFileNameNoExt( goFile ); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar; GameObjectCollection ggo = new GameObjectCollection( goFile ); ggo.Export( outBaseName + m_project.GetGreatGameObjectName( goFile ), m_project ); } Debug.Log("Export is finished!"); }
// void ExportAll() { // string outFileName = EditorUtility.SaveFilePanel("Select folder to export to", m_lastExportDirectory, "filenameignored", "bin"); // m_lastExportDirectory = System.IO.Path.GetDirectoryName(outFileName); SaveLastExportDirectory(); m_project.Export(m_lastExportDirectory); // // Export all images // string[] imageFiles = m_project.m_imageFiles; foreach (string imageFile in imageFiles) { Debug.Log("Exporting file '" + imageFile + "'"); string outFileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(imageFile).ToLower(); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar + outFileNameNoExt; // PalettizedImageConfig imageConfig = new PalettizedImageConfig(imageFile + ".config"); PalettizedImage imageData = PalettizedImage.LoadImage(imageFile, imageConfig); // if (imageData != null) { // imageConfig.SetImage(imageData); // Convert to tile banks / planar images // PlanarImage planarImage = new PlanarImage( imageData); TileBank tileBank = new TileBank(imageData, (imageConfig.m_importAsSprite == false)); TilePalette tilePalette = new TilePalette(imageData); // Export it if (imageConfig.m_importAsSprite) { Sprite sprite = new Sprite(imageConfig); string alternativeAmigaSpriteName; if (imageConfig.m_importAsBSprite) { AmigaSprite amigaSprite = new AmigaSprite(imageData, imageConfig); alternativeAmigaSpriteName = "_sprite_bank_amiga_b_hw.bin"; amigaSprite.Export(outBaseName + alternativeAmigaSpriteName); } else { AmigaBob amigaBob = new AmigaBob(imageData, imageConfig); alternativeAmigaSpriteName = "_sprite_bank_amiga_a_bob.bin"; amigaBob.Export(outBaseName + alternativeAmigaSpriteName); } tileBank.ExportMegaDrive(outBaseName + "_sprite_bank.bin"); tilePalette.Export(outBaseName + "_palette.bin"); sprite.Export(outBaseName + "_sprite.bin"); } else { TileMap tileMap = new TileMap(tileBank, imageData); tileBank.ExportMegaDrive(outBaseName + "_bank.bin"); tileBank.ExportAmiga(outBaseName + "_bank_amiga.bin"); tileMap.Export(outBaseName + "_map.bin"); tilePalette.Export(outBaseName + "_palette.bin"); } } } // // Export all maps // string[] mapFiles = m_project.m_mapFiles; foreach (string mapFile in mapFiles) { Debug.Log("Exporting map '" + mapFile + "'"); string outFileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(mapFile).ToLower(); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar + outFileNameNoExt; // TileMap tileMap = TileMap.LoadJson(mapFile); CollisionMap collisionmap = new CollisionMap(tileMap); tileMap.Export(outBaseName + "_map.bin"); collisionmap.Export(outBaseName + "_collisionmap.bin"); } // // Export all game objects // foreach (string goFile in m_project.m_gameObjectCollectionFiles) { Debug.Log("Exporting game object '" + goFile + "'"); string outFileNameNoExt = m_project.GetOutFileNameNoExt(goFile); string outBaseName = m_lastExportDirectory + System.IO.Path.DirectorySeparatorChar; GameObjectCollection ggo = new GameObjectCollection(goFile); ggo.Export(outBaseName + m_project.GetGreatGameObjectName(goFile), m_project); } Debug.Log("Export is finished!"); }
void LoadBMP(string _path) { m_openImageName = "<Untitled>"; // Load corresponding config first as it have information on how the image should be loaded m_currentImageConfig = new PalettizedImageConfig(_path + ".config"); m_haveLoadedImage = true; m_currentImageData = PalettizedImage.LoadImage(_path, m_currentImageConfig); if (m_currentImageData != null) { // m_currentImageConfig.SetImage(m_currentImageData); // m_currentFramesString = m_currentImageConfig.GetNumFrames().ToString(); m_currentFrameTimesString = new Dictionary <int, string>(); int iFrame; for (iFrame = 0; iFrame < m_currentImageConfig.GetNumFrames(); iFrame++) { m_currentFrameTimesString[iFrame] = m_currentImageConfig.GetFrameTime(iFrame).ToString(); } // m_openImageName = System.IO.Path.GetFileNameWithoutExtension(_path); m_tileBankWindowRect = new Rect(m_projectWindowWidth + (m_windowPadding * 2.0f), m_windowTop, m_currentImageData.m_width * 2.0f + 10.0f, m_currentImageData.m_height * 2.0f + 10.0f + 15.0f); m_imageSettingsRect = new Rect(m_tileBankWindowRect.x + m_tileBankWindowRect.width + m_windowPadding, m_tileBankWindowRect.y, 200.0f, 200.0f); m_paletteRemapRect = new Rect(m_imageSettingsRect.x + m_imageSettingsRect.width + m_windowPadding, m_imageSettingsRect.y, 100.0f, 15.0f + (16.0f * 30.0f)); // // m_planarImage = new PlanarImage( m_currentImageData); bool OptimizedTilebank = (m_currentImageConfig.m_importAsSprite == false); // If we import the image as a sprite we should not optimize the tile bank m_tileBank = new TileBank(m_currentImageData, OptimizedTilebank); m_tileMap = new TileMap(m_tileBank, m_currentImageData); m_tilePalette = new TilePalette(m_currentImageData); // int w, h; w = m_currentImageData.m_width; h = m_currentImageData.m_height; // m_imageTexture = new Texture2D(w, h, TextureFormat.ARGB32, false); m_imageTexture.filterMode = FilterMode.Point; // int x, y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { int ii = ((h - 1 - y) * w) + x; int ic = m_currentImageData.m_image[ii]; Color col = m_currentImageData.m_palette[ic]; m_imageTexture.SetPixel(x, y, col); } } // m_imageTexture.Apply(); } }
/// <summary> /// Custom Inspector /// </summary> public override void OnInspectorGUI() { // Start custom Inspector serializedObject.Update(); EditorGUI.BeginChangeCheck(); m_target.layerIndex = m_reorderableTilemapLayerList.index; if (m_target.toolIndex > 0 && m_target.toolIndex < 5) { Tools.hidden = true; } else { Tools.hidden = false; } // // References // m_showReferencesGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showReferencesGroup.isExpanded, "References"); if (m_showReferencesGroup.isExpanded) { GUILayout.Space(1); // Standard diffuse shader GUI.color = m_greenColor; if (!m_legacyShader.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_legacyShader, m_guiContent[7]); // Universal diffuse shader GUI.color = m_greenColor; if (!m_universalShader.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_universalShader, m_guiContent[8]); GUI.color = Color.white; } EditorGUILayout.EndFoldoutHeaderGroup(); // // Settings // m_showSettingsGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showSettingsGroup.isExpanded, "Settings"); if (m_showSettingsGroup.isExpanded) { GUILayout.Space(1); // Render pipeline EditorGUILayout.PropertyField(m_renderPipeline, m_guiContent[9]); if (m_target.renderPipeline == TilemapSystemPipeline.Universal) { EditorGUILayout.HelpBox("Universal Render Pipeline is still a work in progress and is not fully functional.", MessageType.Info); } // Tilemap size EditorGUILayout.IntPopup(m_tilesetSize, m_tilesetSizeContentArray, m_tilesetSizeArray, m_guiContent[16]); // Grid size EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField(m_guiContent[0]); m_gridMapSize.x = EditorGUILayout.IntField(m_guiContent[1], (int)m_target.gridMapSize.x); m_gridMapSize.y = EditorGUILayout.IntField(m_guiContent[2], (int)m_target.gridMapSize.y); EditorGUILayout.EndVertical(); // Layer list m_reorderableTilemapLayerList.DoLayoutList(); } EditorGUILayout.EndFoldoutHeaderGroup(); // // Data // m_showDataGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showDataGroup.isExpanded, "Data"); if (m_showDataGroup.isExpanded) { GUILayout.Space(1); if (m_reorderableTilemapLayerList.count > 0) { EditorGUI.BeginDisabledGroup(true); // Tilemap data if (!m_tilemapData.objectReferenceValue) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_tilemapData, m_guiContent[6]); GUI.color = Color.white; // Tilemap texture field if (!m_target.tilemapTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[13], m_target.tilemapTexture, typeof(Texture3D), false); GUI.color = Color.white; // Tileset texture field if (!m_target.tilesetTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[15], m_target.tilesetTexture, typeof(Texture3D), false); GUI.color = Color.white; // Array texture field if (!m_target.layerArrayTexture) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[17], m_target.layerArrayTexture, typeof(Texture2D), false); GUI.color = Color.white; // Render material field if (!m_target.renderMaterial) { GUI.color = m_redColor; } EditorGUI.ObjectField(EditorGUILayout.GetControlRect(), m_guiContent[14], m_target.renderMaterial, typeof(Material), false); GUI.color = Color.white; EditorGUI.EndDisabledGroup(); // Button if (GUILayout.Button("Generate Tilemap Data")) { m_target.GenerateTilemapData(); if (m_target.tilemapData) { TilePalette[] palettes = new TilePalette[m_target.tilemapLayerList.Count]; int[] tilesCount = new int[m_target.tilemapLayerList.Count]; for (int i = 0; i < palettes.Length; i++) { palettes[i] = m_target.tilemapLayerList[i].tilePalette; if (palettes[i]) { tilesCount[i] = m_target.tilemapLayerList[i].tilePalette.tilesCount; } else { tilesCount[i] = 0; } } m_target.tilemapData.settingsState = new TilemapSettings(m_target.tilemapLayerList.Count, tilesCount, palettes, (int)m_gridMapSize.x, (int)m_gridMapSize.y, m_tilesetSize.intValue); m_target.tilemapData.layerIntensity = new float[m_target.tilemapLayerList.Count]; } } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Painting // m_showPantingGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showPantingGroup.isExpanded, "Painting"); if (m_showPantingGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { // Tile palette field EditorGUILayout.BeginVertical("Box"); m_tilePalette = m_reorderableTilemapLayerList.serializedProperty.GetArrayElementAtIndex(m_target.layerIndex).FindPropertyRelative("tilePalette"); GUI.color = m_greenColor; if (!m_tilePalette.objectReferenceValue) { GUI.color = m_redColor; } EditorGUILayout.PropertyField(m_tilePalette, m_guiContent[5]); GUI.color = Color.white; EditorGUILayout.EndVertical(); if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { // Painting mode EditorGUILayout.BeginVertical("Box"); EditorGUILayout.PropertyField(m_paintingMode, m_guiContent[10]); // Auto tile layout popup if (m_target.paintingMode == TilemapSystemPaintingMode.AutoTiles) { m_autoTileElements = GetAutoTileElements(); if (m_autoTileElements.Length > 0) { m_autoTileLayoutIndex = m_reorderableTilemapLayerList.serializedProperty.GetArrayElementAtIndex(m_target.layerIndex).FindPropertyRelative("layoutIndex"); m_autoTileLayoutIndex.intValue = EditorGUILayout.Popup(m_guiContent[17], m_autoTileLayoutIndex.intValue, m_autoTileElements); } else { EditorGUILayout.HelpBox("The Auto Tile list is empty. Please, set some auto tile layout first.", MessageType.Error); } } EditorGUILayout.EndVertical(); GUILayout.Space(-3); if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { EditorGUILayout.BeginVertical("Box"); if (m_target.tilesetTexture) { if (CanPaint()) { // Reset layer button if (GUILayout.Button("Reset This Layer Using the Selected Tile")) { // Register the texture in the undo stack Undo.RegisterCompleteObjectUndo(m_target.tilemapTexture, "Tilemap Change"); m_target.ResetLayer(m_target.layerIndex); } // Toolbar EditorGUILayout.BeginHorizontal(); m_isPicking = m_target.toolIndex == 1 ? true : false; if (GUILayout.Toggle(m_isPicking, m_paintingToolIcons[0], EditorStyles.miniButtonLeft)) { m_target.toolIndex = 1; } else if (m_target.toolIndex == 1) { m_target.toolIndex = 0; } m_isPainting = m_target.toolIndex == 2 ? true : false; if (GUILayout.Toggle(m_isPainting, m_paintingToolIcons[1], EditorStyles.miniButtonMid)) { m_target.toolIndex = 2; } else if (m_target.toolIndex == 2) { m_target.toolIndex = 0; } m_isFilling = m_target.toolIndex == 3 ? true : false; if (GUILayout.Toggle(m_isFilling, m_paintingToolIcons[2], EditorStyles.miniButtonMid)) { m_target.toolIndex = 3; } else if (m_target.toolIndex == 3) { m_target.toolIndex = 0; } m_isErasing = m_target.toolIndex == 4 ? true : false; if (GUILayout.Toggle(m_isErasing, m_paintingToolIcons[3], EditorStyles.miniButtonRight)) { m_target.toolIndex = 4; } else if (m_target.toolIndex == 4) { m_target.toolIndex = 0; } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("It looks like you have changed some settings. Please, regenerate the Tilemap Data to update the 3D Textures.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no Tileset Texture yet. Please, regenerate the Tilemap Data again to create the 3D Tileset texture so you can start painting.", MessageType.Error); } // Tile grid m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos); EditorGUILayout.LabelField("", GUILayout.Width(442)); GUILayout.Space(-20); m_buttonIndex = 0; // Start the selectable loop for (int vertical = 0; vertical < 256;) { m_controlRect = EditorGUILayout.GetControlRect(GUILayout.Width(24), GUILayout.Height(24)); EditorGUILayout.BeginHorizontal(); for (int horizontal = 0; horizontal < 16; horizontal++) { // Get the tile texture m_tileTexture = m_target.tilemapLayerList[m_target.layerIndex].tilePalette.temporaryTileTextureArray[vertical] ? m_target.tilemapLayerList[m_target.layerIndex].tilePalette.temporaryTileTextureArray[vertical] : emptyIconTexture; // Draw the selectable button m_isSelected = m_target.tileIndex == m_buttonIndex ? true : false; if (GUI.Toggle(m_controlRect, m_isSelected, GUIContent.none, GUI.skin.button)) { m_target.tileIndex = m_buttonIndex; } // Draw the tile texture if (m_isSelected) { GUI.color = m_selectedTileColor; } GUI.DrawTexture(m_controlRect, m_tileTexture, ScaleMode.StretchToFill, true, 0); GUI.color = Color.white; m_controlRect.x += 28; vertical++; m_buttonIndex++; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Auto tiles // m_showAutoTileGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showAutoTileGroup.isExpanded, "Auto Tiles"); if (m_showAutoTileGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here GUILayout.Space(3); m_autoTileDictionary[m_target.layerIndex].DoLayoutList(); } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // // Random tile painting // EditorGUI.BeginDisabledGroup(true); m_showRandomTilePaintingGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showRandomTilePaintingGroup.isExpanded, "Random Tile Painting"); if (m_showRandomTilePaintingGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // Random tiles m_showRandomizeTileGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showRandomizeTileGroup.isExpanded, "Randomize Tiles"); if (m_showRandomizeTileGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); // Tile brushes m_showTileBrushesGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showTileBrushesGroup.isExpanded, "Tile Brushes"); if (m_showTileBrushesGroup.isExpanded) { if (m_reorderableTilemapLayerList.count > 0 && m_target.layerIndex >= 0 && m_target.tilemapLayerList.Count > 0) { if (m_tilemapData.objectReferenceValue) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette) { if (m_target.tilemapLayerList[m_target.layerIndex].tilePalette.tilesCount > 0) { // Editor stuff here } else { EditorGUILayout.HelpBox("The Tile Palette used in this layer is empty. Please, add the tiles to the Tile Palette first.", MessageType.Error); } } else { EditorGUILayout.HelpBox("The tile palette of this layer is missing! Add a Tile Palette to start painting.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no tilemap data created yet! Generate the Tilemap Data.", MessageType.Error); } } else { EditorGUILayout.HelpBox("There is no layer created yet! Create a tilemap layer.", MessageType.Error); } } EditorGUILayout.EndFoldoutHeaderGroup(); EditorGUI.EndDisabledGroup(); // About group m_showAboutGroup.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(m_showAboutGroup.isExpanded, "About"); if (m_showAboutGroup.isExpanded) { EditorGUILayout.HelpBox("3D Tilemap System v1.0.0 by Seven Stars Games", MessageType.None); if (GUILayout.Button(m_guiContent[18])) { Application.OpenURL("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=S8AB7CVH5VMZS&source=url"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("My other assets you may like:"); if (GUILayout.Button(m_guiContent[19])) { Application.OpenURL("https://assetstore.unity.com/packages/tools/particles-effects/azure-sky-dynamic-skybox-36050"); } if (GUILayout.Button(m_guiContent[20])) { Application.OpenURL("https://assetstore.unity.com/packages/vfx/shaders/azure-sky-lite-89858"); } } // Update layer intensity when there is a change in the Inspector if (m_target.tilemapData) { if (NeedUpdateLayerIntensity()) { m_target.UpdateLayerSettings(); m_target.tilemapData.layerIntensity = new float[m_target.tilemapLayerList.Count]; for (int i = 0; i < m_target.tilemapLayerList.Count; i++) { m_target.tilemapData.layerIntensity[i] = m_target.tilemapLayerList[i].intensity; } } } // End custom Inspector if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_target, "3D Tilemap System"); serializedObject.ApplyModifiedProperties(); m_target.gridMapSize = m_gridMapSize; m_target.UpdateMaterialSettings(); } }