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 KristianGrytdal · Jul 30, 2016 at 10:26 AM · c#sceneimageinputfield

Changing something in another scene by answering correctly

I'm making a guess the movie game, and I wondered if anybody know how I can make it so. When a person answers correctly, the button with a image on the other scene needs to change. So I need a script that changes puts a image or something over the button on the other scene. This is the script that that i need to put it in------ using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement;

public class Spawn: MonoBehaviour {

 private string gameName;

 private int countGuess;

 [SerializeField]
 private InputField input;

 [SerializeField]
 private Text text;

 void Awake(){
     gameName = "spawn";
     text.text = "Guess The Name Of The Game";
 }
 public void GetInput(string guess){
     CompareGuesses(guess);
     input.text = "";
 }
 public void CompareGuesses (string guess){
     if (guess == gameName) {
         text.text = "You Guessed Correctly";
         SceneManager.LoadScene("Level 1");
     } else if (guess != gameName) {
         text.text = "Wrong!";
     } else if (guess != gameName) {
         text.text = "Wrong!";
     }
 }

}

Comment
Add comment · Show 2
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 Sethhalocat · Jul 30, 2016 at 12:18 PM 1
Share

Add a few gameobjects in your variables and have a specific one spawn when a seperate script knows the answer is true. $$anonymous$$eep that script in a do not destroy functions, Preferably make an empty game object that detects which button is clicked through public variables and have that go through to the next scene. then have the next scene look at the game object that has now been carried on and have it detect weather or not the before answer was correct (true) or wrong (false) when wrong have it spawn in the "wrong" object you want and when correct have it spawn in the correct object. If you would like i can give you an example, that might be hard to understand.

avatar image KristianGrytdal Sethhalocat · Aug 03, 2016 at 12:55 PM 0
Share

It would be great if you could make an example for me. I'm pretty new to scripting so I need a loot of help :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Rodoleia · Jul 30, 2016 at 04:35 PM

@KristianGrytdal If you have a lot of different scenes in your game and you want to transfer a data bettween them, i think you need some GlobalManager object, wich will present in your game constantly, no matter what scene is active now.

  1. The most simple way to achieve this is to create gameobject with attached GlobalManager script to it in your initial scene. Then you just add DontDestroyOnLoad method to this script (https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html) and it will be not destroyed when you load any others scene. You can store any data you need in this script, and then load any scene with corrent parameters (button images etc), extracted from it.

  2. Here is a bit more complicated, but globally more correct way to create a GlobalManager object as a singleton(it ensurance that it will be only one GlobalManager object in your game): https://unity3d.com/ru/learn/tutorials/projects/2d-roguelike-tutorial/writing-game-manager if you don't know what singleton is, chech this out: https://en.wikipedia.org/wiki/Singleton_pattern

Comment
Add comment · Show 1 · 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 KristianGrytdal · Jul 31, 2016 at 11:23 PM 0
Share

So I if i make a image an put the Global$$anonymous$$anager and DontDestroyOnLoad script on it, in the scene that dosn't have the InputField. Then I go to the scene with the InputField, and should be able to find it there. But do I need to do something with the script that is on the InputField(The script that says what happends when a person answers correctly) . or how do i do it so the image becomes visible when the person answers correctly?.

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

6 People are following this question.

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

Related Questions

Making an image appear from a different script 0 Answers

How do i check if correct image is dragged in the panel?? 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Change Scene by answering right 3 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