Skip to content

Instantly share code, notes, and snippets.

@suakig
Created April 23, 2015 22:47
Show Gist options
  • Save suakig/a9c11dc9995fd355a1c7 to your computer and use it in GitHub Desktop.
Save suakig/a9c11dc9995fd355a1c7 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Weapon : MonoBehaviour {
[System.NonSerialized] public GameObject whoEquip;
Gun[] gun;
void Start ()
{
Transform parent = transform.parent;
while (parent != null) {
if (parent.GetComponent<Equipment> ()) {
whoEquip = parent.gameObject;
break;
}
parent = parent.parent;
}
gun = this.transform.GetComponentsInChildren<Gun> ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment