Search Unity

NullReferenceException

Discussion in 'Scripting' started by eladiorubiohernandez, Jan 19, 2019.

  1. eladiorubiohernandez

    eladiorubiohernandez

    Joined:
    Dec 8, 2018
    Posts:
    1
    Hi, i have a few problems with my scrips and i´m very new to unity and C maybe you can help me.

    NullReferenceException: Object reference not set to an instance of an object
    ERH.CardType.OnSetType (ERH.CardViz viz) (at Assets/Complex/Scripts/Cards/CardType.cs:13)
    ERH.AttackCard.OnSetType (ERH.CardViz viz) (at Assets/Complex/Scripts/Cards/AttackCard.cs:11)
    ERH.CardViz.LoadCard (ERH.Card c) (at Assets/Complex/Scripts/Cards/CardViz.cs:25)
    ERH.CardViz.Start () (at Assets/Complex/Scripts/Cards/CardViz.cs:15)

    Here ist the script CardType.cs

    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.
    5. namespace ERH
    6. {
    7. public abstract class CardType : ScriptableObject
    8. {
    9. public string typeName;
    10.
    11. public virtual void OnSetType(CardViz viz)
    12. {
    13. Element t = Settings.GetResourcesManager().typeElement;
    14. CardVizProperties type = viz.GetProperty(t);
    15. type.text.text = typeName;
    16 }
    17. }
    18.}

    Thanks in advance!
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Either Settings (unless it's static) or the results of GetResourcesManager() is null, which means it doesn't hold a proper value. You must have missed assigning it somewhere else.