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 RemDust · Mar 20, 2017 at 02:31 PM · scripting problemreferencingasynchronous

Set AsyncOperation.allowSceneActivation from another script ?

Hi guys ! I'd like to be able to delay the scene activation but I just can't get to call alloSceneActivation from another script :/

I guess I just don't know how to get a reference to the proper async operation that is waiting for activation here !

Any help would be great :D

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ExtinctSpecie · Mar 20, 2017 at 03:07 PM

if you need any help leave a comment below so basically i have a separate scene (loading scene) which has the below script attached to it

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class LoadingSceneController : MonoBehaviour {
     
     [Header("Loading Visuals")]
     public Image background;
     public Image progressBar;
     public Image fadeOut;
     public Text loadingText;
     [Header("Timing Settings")]
     public float waitOnLoadEnd;
     [Header("Loading Settings")]
     public ThreadPriority loadThreadPriority;
 
     AsyncOperation operation;
 
     public static int loadingSceneIndex = 1;
     public static string sceneNameToLoad = "";
     public static int sceneIndexToLoad = -1;
 
     void Start()
     {
         GetComponent<AudioSource> ().volume = Volume_Controller.get_sfx_volume();
         Debug.Log (sceneNameToLoad);
         Debug.Log ("Loading scene is loaded");
         StartCoroutine (CoLoadSceneAsyncByName ());
     }
     public static void LoadSceneByName(string sceneName)
     {
         Application.backgroundLoadingPriority = ThreadPriority.High;
         SceneManager.LoadScene(loadingSceneIndex);
         sceneNameToLoad = sceneName;
     }
     public static void LoadSceneByIndex(int sceneIndex)
     {
         Application.backgroundLoadingPriority = ThreadPriority.High;
         SceneManager.LoadScene(loadingSceneIndex);
         sceneIndexToLoad = sceneIndex;
     }
     IEnumerator CoLoadSceneAsyncByName()
     {
         InitializeVisuals ();
         yield return null;
 
         Application.backgroundLoadingPriority = loadThreadPriority;
 
         operation = SceneManager.LoadSceneAsync (sceneNameToLoad);
 
         while (!operation.isDone) 
         {
             progressBar.fillAmount = operation.progress;
             yield return null;
         }
         yield return new WaitForSeconds (waitOnLoadEnd);
 
         LoadingDone ();
 
         yield return new WaitForSeconds (0.1f);
         operation.allowSceneActivation = true;
     }
     public void InitializeVisuals()
     {
         progressBar.fillAmount = 0f;
         loadingText.text = "Loading...";
     }
     public void LoadingDone()
     {
         progressBar.fillAmount = 1f;
         loadingText.text = "Loading Done.";
     }
 
 }
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 ExtinctSpecie · Mar 20, 2017 at 03:11 PM 0
Share

LoadSceneByIndex wont work it needs its own Co-Routine this will throw an error if you try to call it

avatar image RemDust · Mar 20, 2017 at 03:50 PM 0
Share

This doesn't actually answer my problem :$

I want to be able to wait once LoadingDone(); and actually set allowsceneActivation to true FRO$$anonymous$$ ANOTHER SCRIPT. :/

avatar image ExtinctSpecie RemDust · Mar 20, 2017 at 04:43 PM 0
Share

so create a function and call it on button click or get access to the component(script) or create a listener public void ActivateScene() { operation.allowSceneActivation = true; }

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

89 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

Related Questions

damage function not calling 0 Answers

Help with adding variables to other script 2 Answers

how do i refer to a instantiated gameobject? 1 Answer

Duplicating Component with Some Scene References in Serialized Scriptable Object Class Reference 0 Answers

How to reference a variable list 2 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