From 2abeb86464655ba4046bdf23edde553fd18d1172 Mon Sep 17 00:00:00 2001 From: 7StarsGames Date: Sat, 4 Jul 2020 09:23:37 -0300 Subject: [PATCH] Add files via upload --- .../Editor/TilemapSystemInspector.cs | 4 +- 3D Tilemap System/Scripts/TilemapSystem3D.cs | 62 +++++++++++++++++-- .../Utilities/TilemapSystem3DEditorStuffs.cs | 54 ---------------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/3D Tilemap System/Editor/TilemapSystemInspector.cs b/3D Tilemap System/Editor/TilemapSystemInspector.cs index a56df9b..26e68e4 100644 --- a/3D Tilemap System/Editor/TilemapSystemInspector.cs +++ b/3D Tilemap System/Editor/TilemapSystemInspector.cs @@ -603,7 +603,7 @@ public override void OnInspectorGUI() 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); + EditorGUILayout.HelpBox("3D Tilemap System v1.0.1 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"); @@ -707,7 +707,7 @@ private void OnSceneGUI() // Pickup the tile if (m_target.toolIndex == 1) { - m_target.PickupTile((int) hitCoord.x, (int) hitCoord.y, m_target.layerIndex); + m_target.tileIndex = m_target.PickupTile((int) hitCoord.x, (int) hitCoord.y, m_target.layerIndex); m_isPaintingEvent = false; Repaint(); } diff --git a/3D Tilemap System/Scripts/TilemapSystem3D.cs b/3D Tilemap System/Scripts/TilemapSystem3D.cs index 9dda9d5..ef0fb28 100644 --- a/3D Tilemap System/Scripts/TilemapSystem3D.cs +++ b/3D Tilemap System/Scripts/TilemapSystem3D.cs @@ -156,7 +156,7 @@ public void UpdateRenderMaterial() materialPropertyBlock.SetVector(GridMapSize, gridMapSize); // Set the material to the terrain or custom mesh - #if UNITY_EDITOR + //#if UNITY_EDITOR Terrain terrainComponent = gameObject.GetComponent(); if (terrainComponent) { @@ -170,7 +170,7 @@ public void UpdateRenderMaterial() rendererComponent.material = renderMaterial; rendererComponent.SetPropertyBlock(materialPropertyBlock); } - #endif + //#endif } /// @@ -200,9 +200,9 @@ public float GetLayerIntensity(int layer) /// /// Pickup the index of the clicked tile on the mesh. /// - public void PickupTile(int x, int y, int layer) + public int PickupTile(int x, int y, int layer) { - tileIndex = (int) (tilemapTexture.GetPixel(x, y, layer).r * 255); + return (int) (tilemapTexture.GetPixel(x, y, layer).r * 255); } /// @@ -619,6 +619,60 @@ public void EraseAutoTile(int x, int y, int layoutIndex, int layer) tilemapTexture.Apply(); } + /// + /// Copy a tilemap slice and save into a Texture2D. + /// + private Texture2D GetTexture3DSlice(Texture3D texture, int depth) + { + // Creates the temporary Texture2D + Texture2D tempTexture = new Texture2D(texture.width, texture.height, texture.format, false) + { + name = "Slice Texture", + filterMode = FilterMode.Point, + wrapMode = TextureWrapMode.Clamp, + anisoLevel = 0 + }; + + // Copy the 3D texture slice color to the temporary Texture2D + for (int i = 0; i < texture.width; i++) + { + for (int j = 0; j < texture.height; j++) + { + Color32 tempColor = texture.GetPixel(i, j, depth); + tempTexture.SetPixel(i, j, tempColor); + } + } + + // Apply the changes to the temporary Texture2D and return + tempTexture.Apply(); + return tempTexture; + } + + /// + /// Paste a Texture2D to a tilemap slice. + /// + private void SetTexture3DSlice(Texture2D sourceTex2D, Texture3D targetTex3D, int depth) + { + // Get the color of the source Texture2D + Color32[] newColor = sourceTex2D.GetPixels32(); + + // Used to access each index of the color array + int index = 0; + + // Paste the Texture2D color into the tilemap slice pixel by pixel + for (int i = 0; i < targetTex3D.width; i++) + { + for (int j = 0; j < targetTex3D.height; j++) + { + targetTex3D.SetPixel(j, i, depth, newColor[index]); + index++; + } + } + + // Apply the changes to the tilemap texture + targetTex3D.Apply(); + } + /// /// Get the value of an array using a 2D coordinate as a parameter. /// diff --git a/3D Tilemap System/Scripts/Utilities/TilemapSystem3DEditorStuffs.cs b/3D Tilemap System/Scripts/Utilities/TilemapSystem3DEditorStuffs.cs index 70f7302..5ffc2fd 100644 --- a/3D Tilemap System/Scripts/Utilities/TilemapSystem3DEditorStuffs.cs +++ b/3D Tilemap System/Scripts/Utilities/TilemapSystem3DEditorStuffs.cs @@ -442,60 +442,6 @@ public void UpdateMaterialSettings() } } - /// - /// Copy a tilemap slice and save into a Texture2D. - /// - private Texture2D GetTexture3DSlice(Texture3D texture, int depth) - { - // Creates the temporary Texture2D - Texture2D tempTexture = new Texture2D(texture.width, texture.height, texture.format, false) - { - name = "Slice Texture", - filterMode = FilterMode.Point, - wrapMode = TextureWrapMode.Clamp, - anisoLevel = 0 - }; - - // Copy the 3D texture slice color to the temporary Texture2D - for (int i = 0; i < texture.width; i++) - { - for (int j = 0; j < texture.height; j++) - { - Color32 tempColor = texture.GetPixel(i, j, depth); - tempTexture.SetPixel(i, j, tempColor); - } - } - - // Apply the changes to the temporary Texture2D and return - tempTexture.Apply(); - return tempTexture; - } - - /// - /// Paste a Texture2D to a tilemap slice. - /// - private void SetTexture3DSlice(Texture2D sourceTex2D, Texture3D targetTex3D, int depth) - { - // Get the color of the source Texture2D - Color32[] newColor = sourceTex2D.GetPixels32(); - - // Used to access each index of the color array - int index = 0; - - // Paste the Texture2D color into the tilemap slice pixel by pixel - for (int i = 0; i < targetTex3D.width; i++) - { - for (int j = 0; j < targetTex3D.height; j++) - { - targetTex3D.SetPixel(j, i, depth, newColor[index]); - index++; - } - } - - // Apply the changes to the tilemap texture - targetTex3D.Apply(); - } - /// /// Copy the tilemap slice of the selected layer and save it temporarily into the clipboard property of the TilemapData ///