Question by
AshAl1 · Dec 30, 2015 at 06:50 AM ·
animator controllerresourceresource.load
Resources won't load in my scene at runtime in unity 5?
I have implemented a helper script using a youtube example. But when I use the Resource method in my other scripts the compiler gives an null Reference error. What am I doing wrong.
this is my helper script and how the resources are called.
using UnityEngine;
using System.Collections;
namespace Helper
{
public class Resource
{
public static string AnimatorController = "System/PlayerAnimator";
}
}
The path according to my scene is Assets/Resources/System/PlayerAnimator.controller
This is how I used in my other scripts to load the resources
private Animator _animator;
private RuntimeAnimatorController _animatorController;
_animatorController = Resources.Load(Resource.AnimatorController) as RuntimeAnimatorController;
_animator.runtimeAnimatorController = _animatorController;
What is the fix for this?
Comment
Just add "/" after "System/PlayerAnimator". Like : "System/PlayerAnimator/" @AshAl1
It didn't work. PlayerAnimator is the controller. Also I have written _animator.GetComponent<Animator>().
too.