Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
7StarsGames committed Jul 4, 2020
1 parent 99e7e96 commit 2abeb86
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions 3D Tilemap System/Editor/TilemapSystemInspector.cs
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
Expand Down
62 changes: 58 additions & 4 deletions 3D Tilemap System/Scripts/TilemapSystem3D.cs
Expand Up @@ -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<Terrain>();
if (terrainComponent)
{
Expand All @@ -170,7 +170,7 @@ public void UpdateRenderMaterial()
rendererComponent.material = renderMaterial;
rendererComponent.SetPropertyBlock(materialPropertyBlock);
}
#endif
//#endif
}

/// <summary>
Expand Down Expand Up @@ -200,9 +200,9 @@ public float GetLayerIntensity(int layer)
/// <summary>
/// Pickup the index of the clicked tile on the mesh.
/// </summary>
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);
}

/// <summary>
Expand Down Expand Up @@ -619,6 +619,60 @@ public void EraseAutoTile(int x, int y, int layoutIndex, int layer)
tilemapTexture.Apply();
}

/// <summary>
/// Copy a tilemap slice and save into a Texture2D.
/// </summary>
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;
}

/// <summary>
/// Paste a Texture2D to a tilemap slice.
/// </summary>
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();
}

/// <summary>
/// Get the value of an array using a 2D coordinate as a parameter.
/// </summary>
Expand Down
54 changes: 0 additions & 54 deletions 3D Tilemap System/Scripts/Utilities/TilemapSystem3DEditorStuffs.cs
Expand Up @@ -442,60 +442,6 @@ public void UpdateMaterialSettings()
}
}

/// <summary>
/// Copy a tilemap slice and save into a Texture2D.
/// </summary>
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;
}

/// <summary>
/// Paste a Texture2D to a tilemap slice.
/// </summary>
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();
}

/// <summary>
/// Copy the tilemap slice of the selected layer and save it temporarily into the clipboard property of the TilemapData
/// </summary>
Expand Down

0 comments on commit 2abeb86

Please sign in to comment.