Search Unity

Couldnt load the script class-message

Discussion in 'Editor & General Support' started by AaronC, Sep 3, 2006.

  1. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    This is an error message-should I bug report it? Im trying to use Neil Carter's(thanks Neil!) script from the wiki, and it says the "cannot derive from monobehavior" message when I reboot.
    Its C#
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class CameraFacingBillboard : MonoBehaviour
    5. {
    6.     public Camera m_Camera;
    7.  
    8.     void Update()
    9.     {
    10.         transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.back,
    11.             m_Camera.transform.rotation * Vector3.up);
    12.     }
    13. }
    It doesnt expose any varibles but please, I am not after a technical scripting answer because I probably wont get it anyway,(I'll stck with javascript as far as learning atm goes) but the instructions on the wiki say it should have a place in the inspector to select the camera.
    I'll try and catch neil on irc
    thanks
    AC
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Unity prints information when something is wrong to the console and the status bar at the bottom.

    So there is an error message, saying the class cant be loaded.
    When you click on the error message, it shows some more info on how to resolve it. Specifically it says:
    "The name of the script has to be the same as the name of the class defined in the script"

    Which means you have to rename the script to be the same as the class name in this case:
    CameraFacingBillboard
     
  3. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Thanks Joachim-got it figured...
    AC