unity – How can I save a scene which consists of continuing text?

I am trying to make a simple book reading app. In scene, it will show only one word from the book every 0.5 seconds. What I want is, when I click pause then quit the game or just back to Main Menu and after returning to Main Menu, when I click to Read Book button, I want to continue from the word I left off. Below is a part of code which will be shown after clicking Read Book button.

void Start()
    textFile = (TextAsset)Resources.Load("FirstBook");
    string texts = textFile.text;

IEnumerator Show(string book)
    yield return new WaitForSeconds(1f);

    string() splitArray = book.Split(' ');
    text = GameObject.FindWithTag("BookText").GetComponent<Text>();

    for (int i = 0; i < splitArray.Length; i++)
        text.GetComponent<Text>().text = (splitArray(i));
        yield return new WaitForSeconds(0.5f);

And below is what I used in my AppManager gameobject for pausing.

private bool paused;
public void ChangePaused()
    if (Time.timeScale == 1 && paused == false) 
        Time.timeScale = 0; 
        Time.timeScale = 1;

My English is not that good so I am having difficulties to explain my problem, if you can’t understand what I need I will try to explain better. Briefly, when I click pause it will keep the word I left off, and then I will back to Main Menu, I will click Read Book button and I will continue from the word I left off. How can I do this?

c# – Prevent Unity From Loading The Next Scene After Getting to the Final Scene

I’m a beginner in Unity, I wrote a script that will load the next scene whenever monsters in a scene are dead. The script is working fine.
Here’s my script.

public void Update()
    if (MonstersAreAllDead())



//Loads The next Level After all the monsters are Confirmed Dead

private void GoToNextLevel()
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);


However, I only have two scenes in my game and When Unity gets to the final scene, it displays an error since there is not next scene to load to.

Scene with build index: 2 couldn't be loaded because it has not been added to the build settings.
To add a scene to the build settings use the menu File->Build Settings...
UnityEngine.SceneManagement.SceneManager:LoadScene (int)
LevelController:GoToNextLevel () (at Assets/Scripts/LevelController.cs:39)
LevelController:Update () (at Assets/Scripts/LevelController.cs:30)

My question. How do I tell unity that it should stop trying to load the next scene and instead Display a message to the user? The message displayed can be something like “This is the final scene”.

Thank you all in advance for your answers.

c# – How to save / load a scene in unity?

There are a few way you can persist data between sessions. To simply name a few you can use playerprefs or a simple file format like xml or json or custom binary files.

As a very simple example, at certain stages in your game (e.g. when a user finishes a level) you can save in a file a number associated with that level (lets say as in your case, 10). If he closes the game and relaunches it, you can load that 10 from the file in the main menu and further see what you want to do with it. (you might want to look into SceneManager.LoadScene(sceneANumber);)

Brackeys had a very nice video explaining those methods step by step if interested:

The last resort would be to use a package such as Easy Save 3 that provides everything needed for a save/load system, including file encryption, however it’s not free.

unity – Why when I move the transform closer to the target by dragging it in the editor in the scene view the target start stuttering and moving back?

The script is attached to a transform that move to a target and than when reaching the target the transform become child of the target.

The script is working fine as it is now but if I drag with the mouse in the editor in the scene view the target to the moving transform while the transform is already moving to the target then the transform start stuttering and even moving back a bit like pushed back some forces pushing it back maybe because I’m using lerp in lines 55,56 ? I want to use lerp but maybe it’s making the problem?

Second if I move the target away from the transform instead trying to chase me and reaching me its doing this problems again.

I want that if I’m dragging and make the target closer to the moving transform than just keep the transform moving to the target and become child when they reaching each other and if I drag the target away from the transform make the transform try to chase me reach me and become child too.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveToTarget : MonoBehaviour
    public enum TransitionState

    public Transform destinationTransform;
    public float speed;
    public float lerpTime;
    public bool isChild = false;

    public AnimationCurve curve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);
    public Transform start;
    public Transform end;
    public float duration = 10.0f;
    private float t;

    private Transform originTransform;
    private float timer;
    private TransitionState state = TransitionState.MovingTowards;
    private Vector3 originTrans;

    void Start()
        t = 0.0f;

        curve.postWrapMode = WrapMode.PingPong;
        originTrans = transform.position;

    void Update()
        switch (state)
            case TransitionState.MovingTowards:
                var v = destinationTransform.position - transform.position;
                if (v.magnitude < 0.001f)
                    state = TransitionState.Transferring;
                    originTransform = destinationTransform;
                    timer = 0;
                Vector3 moveDir = v.normalized;
                //transform.position += moveDir * speed * Time.deltaTime;
                t += Time.deltaTime;
                float s = t / duration;
                transform.position = Vector3.Lerp(originTrans,
                    destinationTransform.position, curve.Evaluate(s));

            case TransitionState.Transferring:
                timer += Time.deltaTime;
                this.transform.position = Vector3.Lerp(originTransform.position, destinationTransform.position, timer);
                if (timer >= 1.0f)
                    this.transform.parent = destinationTransform;
                    isChild = true;
                    state = TransitionState.None;
                    this.enabled = false;

                this.enabled = false;

unity – Particles look different in scene view and game view?

I’m rendering particles and I’m not happy how it looks in the game view.

Why is there a yellow outline in the game view (right) instead of fading nicely into the background like the scene view (left)? Why is it different?

I’m using Universal Render Pipeline and the 2D renderer. The shader is URP/Particles/Unlit and the Color mode is Additive.

I reproduced this in a scene with only a camera and no effects at all.

enter image description here

unity – How do I load scene content but not show it until later?

In my game, I have

  1. A start up scene that has a 1 script. This script loads
  2. The inventory scene
  3. The first level

I don’t want to show the inventory scene, I just want to pre-load it.
Therefore I have put all the objects in the inventory scene into an empty game object named “InventoryRoot”. I have called DontDestroyOnLoad on it.
I want to disable this gameobject after the scene has loaded.
This way, the inventory scene is not shown, but it is “there”. When I want to show the inventory scene, I will call InventoryRoot.setActive(true);

However, I don’t know how to set it non-active from the outside.

My current code is this:

AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("InventoryScene");

// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
    yield return null;
//now I would like to do something like this (pseudo-code):


Later, when I want to show the inventory, I would simply call


I would also like to pass variables to the _InventoryScene and not use playerprefs or similar.

That is why I wanted to learn how to access the rootobject of another scene. I thought I could then in the same way also access scripts in the other scene and pass data to it, for example like this:


game design – Music, scene, or character first

Here’s my personal description, skip if you want:

I’m a high school student and I have three years of JavaScript experience. I made my way and created several project (most left unfinished) that includes database, server, and client. These days, however, Toby Fox got my attention. I finished the game as well as went through lots and lots of community stuff. I got inspired and now I want to give game development a try (I understand game design is different from coding, and I just want to give it a shot). From my past experience on JavaScript, I know there’s no “right way” in terms of styling and designing but more of a personal preferences and that might make this question meaningless, but still I need an answer from experienced. If there’s anything wrong with my question, please tell me as I’m new and I wouldn’t want to make any more mistakes.


I know there’s different aspects of a game: scene, character, story, mechanic, and music (maybe there’s more). I never design my own game before, and I would like to know when brainstorming, which aspect of a game is the best to get started on?

macbook pro – Can I trigger a HomeKit scene when my laptop’s camera is turned on or off?

Like a lot of people nowadays, I’m set up in a home office and I’m often on video calls on my MacBook Pro. My partner sometimes wants to come into my office, but doesn’t want to interrupt a video call. We’ve got a Hue bulb in the landing outside my office, so I was wondering whether I could use that to show whether I’m on a call. Can I trigger a HomeKit scene based on whether my laptop’s camera is turned on or off?