Accessing Mtetadata in Unity

I am trying to access the Metadata from PIXYZ import using the simple code below. and i keep getting errors.

using UnityEngine;

public class DirectComponentRetrieval : MonoBehaviour
{
    void Start()
    {
        // Directly retrieve the Metadata component.
        Metadata metadata = GetComponent<Metadata>();
    }
}

The errors i am getting is:

Assets\DirectComponentRetrieval.cs(10,42): error CS0246: The type or namespace name ‘Metadata’ could not be found (are you missing a using directive or an assembly reference?)

The name of the metadata script as seen on the inspector screen is Metadata.

Can some please help with how to fix this challenge?

1 Answer

1

If there is an error code, like in your case CS0246, it is always a good idea to look up what the error means. In this case, it says that Metadata is not a type that your script assembly knows about. Here are a few common reasons:

  • Typo in the class name
  • Missing using statement
  • If you are using assembly definitions, then a missing reference to the relevant assembly where Metadata comes from.