Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DoctorWatts · Jun 21, 2018 at 01:33 PM · scripting problem

Why am I not able to drag a script into another script's Game Manager anymore?

I have been following along with a YouTuber's tutorials (Brackeys) and have come upon a snag. I am not able to drag and drop my script (GameManager) into the Game Manager of one of my other scripts (End Trigger). This is for my Level 2 scene, I was able to do this before with my Level 1 scene.

I am sorry if this is not detailed enough, I just started two days ago and know little coding.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kciwsolb · Jun 21, 2018 at 01:45 PM 0
Share

You are trying to drag a reference to a Game$$anonymous$$anager script from one GameObject in your hierarchy to a script on another GameObject in your hierarchy that has a field of type Game$$anonymous$$anager, correct? You aren't trying to drag it from the Assets folder, right? Are there any errors in any of your scripts? Unity might not let you drag and drop the reference if it detects any errors. So, check the console.

To get the best answers here, it is best to provide a code sample of your scripts so we can get a better idea of what could be causing the problem. Screenshots of your GameObject's inspector also help, especially in this case. You can format code using the "101010" button and attach pictures using the photo icon (or leave a link to imgur).

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LeeroyLin · Jun 21, 2018 at 01:40 PM

I'm not sure what happened, but you can make sure your GameManager class name is equal to your c# file name. And make sure your GameManager class Inherits from MonoBehaviour. If you still have that problem, you should show me your script.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DoctorWatts · Jun 21, 2018 at 01:58 PM 0
Share

Game$$anonymous$$anager script is: using UnityEngine; using UnityEngine.Scene$$anonymous$$anagement;

public class Game$$anonymous$$anager : $$anonymous$$onoBehaviour {

 bool gameHasEnded = false;
 
 public float restartDelay = 1f;

 public GameObject completeLevelUI;

 public void CompleteLeve1 ()
 {
     completeLevelUI.SetActive(true);
 }

 public void EndGame ()
 {
     if (gameHasEnded == false)
     {
        gameHasEnded = true;
        Debug.Log("GA$$anonymous$$E OVER");
        Invoke("Restart", restartDelay);
     }    
 }   
 
 void Restart ()
 {
  Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().name);
 }  
 

}

End Trigger script is: using UnityEngine;

public class EndTrigger : $$anonymous$$onoBehaviour {

 public Game$$anonymous$$anager game$$anonymous$$anager;

 void OnTriggerEnter()
 {
     game$$anonymous$$anager.CompleteLeve1();
 }

}

This is happening to everything. I cannot drag and drop anything into another script via the Inspector window.

avatar image LeeroyLin DoctorWatts · Jun 21, 2018 at 02:14 PM 0
Share

Ok, I know what you mean and the problem is Game$$anonymous$$anager is a class, and you can only drag a GameObject to your EndTrigger script via the Inspector window. So, you have to drag your Game$$anonymous$$anager script to a GameObject first, even the object your EndTrigger attached. And then drag the GameObject to your EndTrigger's game$$anonymous$$anager property.

avatar image DoctorWatts LeeroyLin · Jun 21, 2018 at 02:30 PM 0
Share

You are right, I had them as objects already and was but was using the scripts ins$$anonymous$$d. Thank you so much.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

151 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

transform/rotate/scale tool callback for drag finished? 0 Answers

How to make W button move towards mouse direction 1 Answer

Cannot access another script's Vector3? 1 Answer

On/Off Trigger is making Light Flicker 1 Answer

Cinemachine errors on Unity 2018.2.0f2 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges