unity – Why the scene name is never change when loading another scene?

I have two scenes. Main Menu and Game.

When running the game it’s starting with the Main Menu scene loaded. Then when making a new game the Main Menu scene is unloaded and the Game scene is loaded but even if the Game scene is loaded it keep showing the Main Menu scene in the name :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class AudioManager : MonoBehaviour
{
    public GameObject gameAudio;

    private AudioSource audioSource;
    private string sceneName;
    private bool currentScene = false;

    void Awake()
    {
        DontDestroyOnLoad(transform.gameObject);
    }

    // Start is called before the first frame update
    void Start()
    {
        // Create a temporary reference to the current scene.
        Scene currentScene = SceneManager.GetActiveScene();

        // Retrieve the name of this scene.
        sceneName = currentScene.name;

        audioSource = gameAudio.GetComponent<AudioSource>();

        var mainmenumusic = GameObject.Find("Main Menu Settings");
        audioSource.volume = mainmenumusic.GetComponent<AudioSource>().volume;
    }

    // Update is called once per frame
    void Update()
    {
        if (sceneName == "Game" && currentScene == false)
        {
            audioSource.Play();
            currentScene = true;
        }
        else
        {
            if (sceneName != "Game")
            {
                audioSource.Stop();
                currentScene = false;
            }
        }
    }

    //Called when Slider is moved
    public void changeVolume(float sliderValue)
    {
        audioSource = gameAudio.GetComponent<AudioSource>();
        audioSource.volume = sliderValue;
    }
}

In the Update even if the Game scene has loaded and only the Game scene is loaded it keep showing Main Menu in the sceneName :

if (sceneName == "Game" && currentScene == false)

sceneName is never “Game”

And a side question :

Why when I press the escape key back to the main menu it keep creating the Dont Destroy On Load object over and over again ? How can I avoid it from being creating the Dont Destroy On Load all the time ? This script is in my Game scene :

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class BackToMainMenu : MonoBehaviour
{
    public GameObject() objsToDisable;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (Time.timeScale == 0)
            {
                DisableEnableUiTexts(true);
                SceneManager.UnloadSceneAsync(0);
                Cursor.visible = false;
                Time.timeScale = 1;
            }
            else
            {
                Time.timeScale = 0;
                MenuController.LoadSceneForSavedGame = false;
                SceneManager.LoadScene(0, LoadSceneMode.Additive);
                SceneManager.sceneLoaded += SceneManager_sceneLoaded;

                Cursor.visible = true;
            }
        }
    }

    private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
    {
        DisableEnableUiTexts(false);
    }

    private void DisableEnableUiTexts(bool enabled)
    {
        foreach (GameObject go in objsToDisable)
        {
            if (go.name == "Cameras")
            {
                foreach(Transform child in go.transform)
                {
                    if(child.name == "Main Camera")
                    {
                        if (enabled == false)
                        {
                            child.GetComponent<Camera>().enabled = false;
                        }
                        else
                        {
                            child.GetComponent<Camera>().enabled = true;
                        }
                    }
                }
            }
            else
            {
                go.SetActive(enabled);
            }
        }
    }
}

domain name system – Can the IP address of a root nameserver change?

Quotation from the IANA page on root servers:

Operators who manage a DNS recursive resolver typically need to
configure a “root hints file”. This file contains the names and IP
addresses of the root servers, so the software can bootstrap the DNS
resolution process. For many pieces of software, this list comes built
into the software
.

(my emphasis)

Therefore, if root servers’ IP addresses changed, software everywhere in the world would have to change, too. To me, this is enough evidence to conclude that these addresses will never change.

EDIT: The first IP address is hardwired into RFC1400. From the RFC:

After the transition, the host.txt file will be available only from
nic.ddn.mil and hosts.txt will include ONLY MILNET HOSTS. On April
1, 1993, a new root DNS server will be placed in service. It will be
available at ns.internic.net ( 198.41.0.4 ).

This indicates that this address will not change as long as this RFC is in effect, but in theory, addresses of other root servers could change. I guess that DNS software should be designed so that it updates the root hints file from ns.internic.net.

c++ – Generating random permutation with forced change of order (Secret Santa)

I wrote this function to generate random permutation of input vector, while making sure every element has switched place (for a Secret Santa like purpose).

std::map<std::string, std::string> getPermutation(const std::vector<std::string>& participants)
{
  auto permuted = participants;
  std::random_device rd;
  std::mt19937 g(rd());
  bool correctlyPermuted = false;
  while(!correctlyPermuted)
  {
    std::shuffle(permuted.begin(), permuted.end(), g);
    auto res = std::mismatch(participants.begin(), participants.end(), permuted.begin(), std::not_equal_to{});
    if(res.first == participants.end())
    {
      correctlyPermuted = true;
    }
  }
  
  std::map<std::string, std::string> result;
  for(int i = 0; i < participants.size(); ++i)
  {
    result(participants(i)) = permuted(i);
  }
  return result;
}

You can run code here. Note that’s still work in progress, I’m mostly concerned about the function above.

participants is guaranteed to contain no duplicate elements.

I’m not really concerned with speed – it’s supposed to be executed by humans, they are unlikely to notice any performance improvement. Of course, you are welcome to point any obvious performance issues.
However, I’m concerned with the readability of the function, particularly with the use of std::mismatch to find actually matching elements. It feels too clever, but maybe it’s just good use of functional programming and I’m overthinking? It also seems too long for a good function (22 lines), but I can’t think of how it could be splitted/shortened logically.

trackpad – MacBook pro 16″ – Big Sur – find config file to change the speed of horizontal scrolling speed

On my MacBook pro 16″, I would like to find out where is the parameter that controls the speed of horizontal scrolling with trackpad (if it is possible).

Indeed, I am using some different editors and I would like to increase the speed of horizontal scrolling, so I wonder if it can be performed by changing parameter(s) in one or different configuration file(s).

In system preferences, there is not such an option that enables to do it (only vertical scrolling speed).

Any information about this is welcome.

theming – How do I change the Font for a “Title Field Label”

I have very little experience with coding but am a fast learner and need to make a change to my page regarding the title field label fonts. They are too small and needs to be bold face.

Can some one please direct me to a list of steps that will take me to the area in my theme (Bartik 8.6.2) so I can make the change. Thank you!

javascript – How can I route change when scroll up and down with reactjs?

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

finder – Change File Picker Dialog folder location (avoid latest visited folder)

Whenever a File picker dialog (MacOs Catalina) is being open by a website or in general within the operating system, the UI shows as a default folder the latest used/visited one.

Let’s consider this typical workflow:

  1. I’m saving a file in Word using the Save button, which brings up a File Picker Dialog and I save my document in let say ~/Desktop/myfolder
  2. After some time (even hours later) a website prompts me for a file Upload, which opens the same File Picker Dialog
  3. Here’s the issue: File Picker Dialog opens – by default- into the latest used folder from the Picker Dialog, so the file Picker UI will show files in ~/Desktop/myfolder.

This is pretty inconvenient as it can expose privacy files when screen-sharing or having someone next on me when using the MacOS.

Is it possible to use a Default folder for the file picker that opens up always for example in ~/Desktop or just ~ ?

python – Altair mark_errorbar change thickness

how can I change the thickness of my errorbar in Altair and when I tried to change my color to black, my color is lighter than it should be, does anyone know why?
the expected output should be
(!(expected output)(1))(1)
but my output is
(!(my output)(2))(2)

here is my code

    alt.X("quantile95", axis=alt.Axis( title="lower",tickMinStep=5),scale=alt.Scale(domain=(0, 55)))
    ).properties(width=450,height=20)```


  (1): https://i.stack.imgur.com/xKFlf.png
  (2): https://i.stack.imgur.com/lgQkP.png