mirror of
https://github.com/appen-isen/jeu-sans-image.git
synced 2026-03-18 21:50:42 +01:00
Slight map creator cleanup
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using Unity.VectorGraphics; // From com.unity.vectorgraphics
|
using Unity.VectorGraphics; // From com.unity.vectorgraphics
|
||||||
@@ -14,10 +13,7 @@ public class SvgToFlatMeshEditor : EditorWindow
|
|||||||
{
|
{
|
||||||
TextAsset svgFile;
|
TextAsset svgFile;
|
||||||
float pixelsPerUnit = 100.0f;
|
float pixelsPerUnit = 100.0f;
|
||||||
Vector2 scale = Vector2.one;
|
|
||||||
Material defaultMaterial;
|
|
||||||
Transform parentTransform;
|
Transform parentTransform;
|
||||||
bool generateColliders = true;
|
|
||||||
float meshScale = 1f;
|
float meshScale = 1f;
|
||||||
VectorUtils.TessellationOptions tessOptions = new VectorUtils.TessellationOptions()
|
VectorUtils.TessellationOptions tessOptions = new VectorUtils.TessellationOptions()
|
||||||
{
|
{
|
||||||
@@ -42,9 +38,7 @@ public class SvgToFlatMeshEditor : EditorWindow
|
|||||||
svgFile = (TextAsset)EditorGUILayout.ObjectField("SVG File (.svg)", svgFile, typeof(TextAsset), false);
|
svgFile = (TextAsset)EditorGUILayout.ObjectField("SVG File (.svg)", svgFile, typeof(TextAsset), false);
|
||||||
pixelsPerUnit = EditorGUILayout.FloatField(new GUIContent("Pixels Per Unit", "Rasterization scale used by VectorUtils. Higher = more detail"), pixelsPerUnit);
|
pixelsPerUnit = EditorGUILayout.FloatField(new GUIContent("Pixels Per Unit", "Rasterization scale used by VectorUtils. Higher = more detail"), pixelsPerUnit);
|
||||||
meshScale = EditorGUILayout.FloatField(new GUIContent("Global Mesh Scale", "Scale applied to resulting mesh in world units"), meshScale);
|
meshScale = EditorGUILayout.FloatField(new GUIContent("Global Mesh Scale", "Scale applied to resulting mesh in world units"), meshScale);
|
||||||
defaultMaterial = (Material)EditorGUILayout.ObjectField("Default Material", defaultMaterial, typeof(Material), false);
|
|
||||||
parentTransform = (Transform)EditorGUILayout.ObjectField("Parent Transform", parentTransform, typeof(Transform), true);
|
parentTransform = (Transform)EditorGUILayout.ObjectField("Parent Transform", parentTransform, typeof(Transform), true);
|
||||||
generateColliders = EditorGUILayout.Toggle("Generate MeshColliders", generateColliders);
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
EditorGUILayout.LabelField("Tessellation Options", EditorStyles.boldLabel);
|
EditorGUILayout.LabelField("Tessellation Options", EditorStyles.boldLabel);
|
||||||
@@ -153,30 +147,12 @@ public class SvgToFlatMeshEditor : EditorWindow
|
|||||||
var mf = go.AddComponent<MeshFilter>();
|
var mf = go.AddComponent<MeshFilter>();
|
||||||
mf.sharedMesh = mesh;
|
mf.sharedMesh = mesh;
|
||||||
|
|
||||||
var mr = go.AddComponent<MeshRenderer>();
|
// Generate collider
|
||||||
if (defaultMaterial != null)
|
|
||||||
{
|
|
||||||
// instantiate a material so each region can have its own color without overwriting the original asset
|
|
||||||
Material matInstance = new Material(defaultMaterial);
|
|
||||||
matInstance.color = color;
|
|
||||||
mr.sharedMaterial = matInstance;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Create a quick default material
|
|
||||||
var mat = new Material(Shader.Find("Standard"));
|
|
||||||
mat.color = color;
|
|
||||||
mr.sharedMaterial = mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (generateColliders)
|
|
||||||
{
|
|
||||||
var mc = go.AddComponent<MeshCollider>();
|
var mc = go.AddComponent<MeshCollider>();
|
||||||
mc.sharedMesh = mesh;
|
mc.sharedMesh = mesh;
|
||||||
mc.convex = false; // keep non-convex for flat terrain; set to true if needed for rigidbodies
|
mc.convex = false; // keep non-convex for flat terrain; set to true if needed for rigidbodies
|
||||||
}
|
|
||||||
|
|
||||||
// Optionally set layer / tag etc. User can attach audio trigger components later to each go.
|
// TODO: automatically assign audio triggers based on color
|
||||||
}
|
}
|
||||||
|
|
||||||
// Focus selection on created container
|
// Focus selection on created container
|
||||||
|
|||||||
Reference in New Issue
Block a user