Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a car game in unity 5.0.4f1. I am facing two snags.

  1. While installing 3.5 net framework, it gives an error. I searched, it took my 2hrs and problem couldn't solve. Then, I reinstalled Unity. For this snag, what is the best solution in a way I won't waste my time anymore?
  2. On the other hand, when I added a C# script using VS community 2015, after dragging the script on the click event, No function doesn't show me the script name in the drop down menu. I'm following this tutorial, tutorial link. At 7:58 he added the script in on function. For me, it is not working.

Game View

using UnityEngine;
using System.Collections;

public class LevelLoader : MonoBehaviour {

    GameObject menu_Canvas;
    GameObject settings_Canvas;

    void Start () {

        menu_Canvas = GameObject.Find ("MainMenu_Canvas");
        settings_Canvas = GameObject.Find ("Settings_Canvas");

        settings_Canvas.SetActive (false);
        menu_Canvas.SetActive (true);
    }

    public void LoadLevel (int a) {

        Application.LoadLevel (a);
    }

    public void Quit () {

        Application.Quit ();
    }

    public void loadMenu () {

        menu_Canvas.SetActive (true);
        settings_Canvas.SetActive (false);
    }

    public void loadSettings () {

        menu_Canvas.SetActive (false);
        settings_Canvas.SetActive (true);
    }
}

Please help, as I have been trapped in the problem since few days.

share|improve this question
    
please share your code.do you place script instead of gameObject to OnClick() field? so you should attach it to gameObject so place it there. do you use public access modifier in your code? – smkplus 2 days ago
    
is LevelLoader added to a gameObject? – Uri Popov 2 days ago
    
@smkplus I updated the question... – Warda yesterday
    
@UriPopov as you can see that I dropped the script file 'LevelLoader' below the Runtime in On Click event. – Warda yesterday
    
I am a newbie for Unity. Can you elaborate what do you mean by LevelLoader added to a gameobject? – Warda yesterday
up vote 0 down vote accepted

Ok you seem to be directly dragging the script to the Onclick event. What you need to do is drag the script onto a game object that is in the scene. Then select that object in the event and then select the script component. Monobehaviours dont work if they are not on a game Object.enter image description here enter image description here

share|improve this answer
    
many thanks!! :) – Warda yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.