-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomImportProcessor.cs
41 lines (35 loc) · 1.25 KB
/
CustomImportProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using UnityEngine;
using UnityEditor;
using System.IO;
using Unity.VisualScripting;
class CustomImportProcessor : AssetPostprocessor
{
void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] names, System.Object[] values)
{
ModelImporter importer = (ModelImporter)assetImporter;
var asset_name = Path.GetFileName(importer.assetPath);
Debug.LogFormat("OnPostprocessGameObjectWithUserProperties(go = {0}) asset = {1}", go.name, asset_name);
if (names.Length == 0)
{
Debug.Log("No user properties found.");
return;
}
var variables = go.GetComponent<Variables>();
if (variables == null)
{
variables = go.AddComponent<Variables>();
}
for (int i = 0; i < names.Length; i++)
{
var name = names[i];
var val = values[i];
Debug.LogFormat("Processing Property : {0} : {1} : {2}", name, val.GetType().Name, val.ToString());
if (val is Vector4)
{
// Convert Vector4 to Vector3
val = (Vector3)(Vector4)val;
}
variables.declarations.Set(name, val);
}
}
}