You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
916 B
39 lines
916 B
namespace Mapbox.Unity.MeshGeneration.Modifiers
|
|
{
|
|
using Mapbox.Unity.MeshGeneration.Data;
|
|
using Mapbox.Unity.MeshGeneration.Components;
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
|
|
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Add Monobehaviours Modifier")]
|
|
public class AddMonoBehavioursModifier : GameObjectModifier
|
|
{
|
|
[SerializeField]
|
|
AddMonoBehavioursModifierType[] _types;
|
|
private HashSet<string> _scripts;
|
|
private string _tempId;
|
|
|
|
public override void Initialize()
|
|
{
|
|
if (_scripts == null)
|
|
{
|
|
_scripts = new HashSet<string>();
|
|
_tempId = string.Empty;
|
|
}
|
|
}
|
|
|
|
public override void Run(VectorEntity ve, UnityTile tile)
|
|
{
|
|
foreach (var t in _types)
|
|
{
|
|
_tempId = ve.GameObject.GetInstanceID() + t.Type.FullName;
|
|
if (!_scripts.Contains(_tempId))
|
|
{
|
|
ve.GameObject.AddComponent(t.Type);
|
|
_scripts.Add(_tempId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |