Skip to content

Commit cbac1a2

Browse files
author
Twitter-kun
committed
Local rotation and scale preservation on import. Flag to reimport model on start (in order to import on instantiation). Removed UNITY_EDITOR declaration for the same purpose.
1 parent 4bfa13a commit cbac1a2

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Assets/MagicaVoxel/Scripts/MVImporter.cs

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ public static GameObject[] CreateVoxelGameObjectsForChunk(MVVoxelChunk chunk, Co
664664
go.name = string.Format ("VoxelMesh ({0})", index);
665665
go.transform.SetParent (parent);
666666
go.transform.localPosition = Vector3.zero;
667+
go.transform.localRotation = Quaternion.Euler (Vector3.zero);
668+
go.transform.localScale = Vector3.one;
667669

668670
MeshFilter mf = go.AddComponent<MeshFilter> ();
669671
mf.mesh = mesh;

Assets/MagicaVoxel/Scripts/MVVoxModel.cs

100644100755
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
public class MVVoxModel : MonoBehaviour {
55

6-
#if UNITY_EDITOR
7-
[HideInInspector]
8-
// not neccessary in runtime
9-
public string ed_filePath = "";
10-
116
[HideInInspector]
127
// not neccessary in runtime
138
public string ed_alphaMaskFilePath = "";
@@ -16,7 +11,8 @@ public class MVVoxModel : MonoBehaviour {
1611
[HideInInspector]
1712
public bool ed_importAsIndividualVoxels = false;
1813

19-
#endif
14+
// actually requred for instantiation
15+
public string ed_filePath = "";
2016

2117
[HideInInspector]
2218
public MVMainChunk vox;
@@ -110,4 +106,12 @@ public void LoadVOXData(byte[] data, bool asIndividualVoxels, byte[] alphaMaskDa
110106
}
111107

112108
}
109+
110+
public bool reimportOnStart = true;
111+
void Start()
112+
{
113+
if (reimportOnStart) {
114+
LoadVOXFile (ed_filePath, ed_alphaMaskFilePath, ed_importAsIndividualVoxels);
115+
}
116+
}
113117
}

MagicaVoxel.unitypackage

142 KB
Binary file not shown.

0 commit comments

Comments
 (0)