Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to make a variable of a script in C#?

Discussion in 'Scripting' started by Mystique, Feb 23, 2015.

  1. Mystique

    Mystique

    Joined:
    Nov 19, 2014
    Posts:
    40
    Sorry for the simple question but I cant find any links, I know that in Javascript its like

    Code (JavaScript):
    1. var variableScript : actualScript;
    In C# I thought it was

    Code (CSharp):
    1. actualScript variableScript;
    but I'm getting errors on such. Any help is welcome

    error log
    error CS0246: The type or namespace name `actualScript' could not be found. Are you missing a using directive or an assembly reference?


    and yes the C# script named actualScript exists.
     
  2. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Can you post the lines above that because your declaration looks just fine for C#
     
  3. Mystique

    Mystique

    Joined:
    Nov 19, 2014
    Posts:
    40
    thanks I figured it out the public class had the wrong name