I'm using the UMACharacterBuilder script to initialize my UMA players at runtime and I'm having NullReferenceException problems at runtime
CapsuleColliderPositioner.cs is throwing NullReferences on awake because its unable to find UltimateCharacterLocation. But ONLY on a build - not the editor.
This code in CharacterBuilder.cs adds the locomotion script - but only if in the editor?
Why?
I've changed it to add it all the time now - I just want to be sure I'm not breaking something
CapsuleColliderPositioner.cs is throwing NullReferences on awake because its unable to find UltimateCharacterLocation. But ONLY on a build - not the editor.
This code in CharacterBuilder.cs adds the locomotion script - but only if in the editor?
Why?
I've changed it to add it all the time now - I just want to be sure I'm not breaking something
Code:
#if UNITY_EDITOR
if (character.GetComponent<UltimateCharacterLocomotion>() == null) {
var characterLocomotion = character.AddComponent<UltimateCharacterLocomotion>();
if (!Application.isPlaying) {
// The Moving state should automatically be added.
var presetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(c_MovingStateGUID);
if (!string.IsNullOrEmpty(presetPath)) {
var preset = UnityEditor.AssetDatabase.LoadAssetAtPath(presetPath, typeof(StateSystem.PersistablePreset)) as StateSystem.PersistablePreset;
if (preset != null) {
var states = characterLocomotion.States;
System.Array.Resize(ref states, states.Length + 1);
// Default must always be at the end.
states[states.Length - 1] = states[0];
states[states.Length - 2] = new StateSystem.State("Moving", preset, null);
characterLocomotion.States = states;
}
}
}
}
#endif
Last edited: