I have 2 scripts
c#
ClothingManager.cs:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
public class ClothingManager {
public List<GameObject> addedClothing = new List<GameObject>();
public string [] clothing = {"Jacket", "Pants", "Dress"};
public NiteController niteController;
public ClothingManager(NiteController nc) {
niteController = nc;
}
public void ToggleClothing(string clothingLabel) {
Debug.Log("Toggling " + clothingLabel);
Vector3 location;
niteController.GetJointPosition(NiteWrapper.SkeletonJoint.TORSO_CENTER, out location);
GameObject clothing = FindActiveClothing(clothingLabel);
if (clothing == null) {
clothing = Object.Instantiate(Resources.Load(clothingLabel), location, Quaternion.identity) as GameObject;
clothing.name = clothingLabel;
if (niteController.RegisterRig(clothing)) {
//Add clothing to list of worn clothing
addedClothing.Add(clothing);
} else {
Object.Destroy(clothing);
Debug.LogWarning("Clothing rig not valid: " + clothingLabel);
}
} else {
addedClothing.Remove(clothing);
Object.Destroy(clothing);
}
}
and a javascript:
var clothingManager : ClothingManager;
function Awake()
{
clothingManager = gameObject.GetComponent(ClothingManager); //get the c#script
}
function Pants()
{
Debug.Log("blablablablabalb");
clothingManager.ToggleClothing("Pants");
}
When I call the funtion Pants I get a nullreferenceexception object reference not set to an instance of an object error
How can I solve this?