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 Would We Attach C# Script To When A Scene Is Shown?

Discussion in 'Scripting' started by JeZxLee, Oct 6, 2016.

  1. JeZxLee

    JeZxLee

    Joined:
    Jul 24, 2016
    Posts:
    222
    Hi,

    We have two scenes now.
    We want the first scene to either display for 5 seconds or accept mouse click to advance to second scene.
    How would we do the above?
    We guess it would be a C# script but we are confused how to attach it to the first scene?
    Any help would be appreciated, thanks!
     
  2. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    Create your script and inherit from MonoBehaviour. This will allow you to attach the script as a component to any GameObject in your scene. I would suggest doing a few tutorials to get familiar with Unity3D...
     
    Last edited: Oct 6, 2016
  3. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    you don't attach scripts to the scene, you attach scripts to GameObjects in the scene. If you want the script to do something on Scene start just Give the MonoBehaviour a Start() method.

    In unity you don't have a entry point where you initialize everything, but you create lots of objects for dealing with individual roles, and setup references between them if they have to talk to eachother.