To attach a script to a game object as component during run time, create a new C# script and paste the below contents.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule.Utilities.Interactions;
public class AttachScript : MonoBehaviour
{
public GameObject DmuModel;
void Start()
{
Transform[] allchild = DmuModel.GetComponentsInChildren<Transform>();
foreach (Transform child in allchild)
{
child.gameObject.AddComponent<MeshCollider>();
child.gameObject.AddComponent<TwoHandManipulatable>();
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule.Utilities.Interactions;
public class AttachScript : MonoBehaviour
{
public GameObject DmuModel;
void Start()
{
Transform[] allchild = DmuModel.GetComponentsInChildren<Transform>();
foreach (Transform child in allchild)
{
child.gameObject.AddComponent<MeshCollider>();
child.gameObject.AddComponent<TwoHandManipulatable>();
}
}
No comments:
Post a Comment