-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperCustomImporter.cs
More file actions
45 lines (38 loc) · 1.43 KB
/
Copy pathSuperCustomImporter.cs
File metadata and controls
45 lines (38 loc) · 1.43 KB
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
42
43
44
45
using UnityEngine;
using SuperTiled2Unity;
using SuperTiled2Unity.Editor;
[AutoCustomTmxImporter]
public class SuperCustomImporter : CustomTmxImporter
{
public override void TmxAssetImported(TmxAssetImportedArgs args)
{
var map = args.ImportedSuperMap;
var allProps = map.GetComponentsInChildren<SuperCustomProperties>();
// Pass 1: object yang punya SuperCustomProperties
foreach (var props in allProps)
{
if (props == null) continue;
var parent = props.transform.parent;
if (parent == null) continue;
if (props.GetComponent<SuperTileLayer>() != null || HasAncestor<SuperTileLayer>(props.transform)) continue;
if (parent.GetComponent<SuperObjectLayer>() == null && parent.GetComponent<SuperGroupLayer>() == null) continue;
var superObject = props.GetComponent<SuperObject>();
}
// Pass 2: semua SuperObject di map (termasuk prefab replacement)
var allSuperObjects = map.GetComponentsInChildren<SuperObject>();
foreach (var superObj in allSuperObjects)
{
if (superObj == null) continue;
}
}
private bool HasAncestor<T>(Transform t) where T : Component
{
var current = t.parent;
while (current != null)
{
if (current.GetComponent<T>() != null) return true;
current = current.parent;
}
return false;
}
}