#Freddy thread
1 messages · Page 1 of 1 (latest)
alr
perfect
no
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ChangeScenes : MonoBehaviour
{
public void Play()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 2);
}
public void Options()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void Quit()
{
Application.Quit();
Debug.Log("Player has quit the game");
}
public void BackToMainMenu()
{
SceneManager.LoadScene(0);
}
}
this is my code for changing scenes
there is another one you had
this one
I dont really understand what are you trying to explain
also srry for my dumbness I have wasted 2 hours of your life
ok stay focused
you're trying to load
and when do you need to load
when scene changes
did you read what the link I've sent does
its really not that complex if you read lol
its in plain english
k srry
subscribing is done with +=
unsubscribe is done with -=
based on that , look in the script where thats happening
when It enables something, it subscribes to Change scene
when disabling, unsubscribing
so when it enables the method, the scene changes
what
when you run LoadScene this is method is run
nothing more, nothing less
Loading anything should go there since you want to load the same stats in the separate scene
unless the script that has that stat is dontdestroyonload
in that cause it never gets destroyed on scene changes
but this can break references if you have any references to other scene objects
using the playerprefs thing is preferrable
how
when I run LoadScene is to get to the other scene, I cant put the brightness thing there
what
all your doing is loading the values from playerpefs
on scene changes
so the post processing has the same value each scene
how do I put that into code?
I meant here
why this script ?
this isn't the script that controls the brightness value
this isnt the script you save value
so in the brightness script I load the save at the start?
Ok
I managed to get something
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Rendering.PostProcessing;
public class Brightness : MonoBehaviour
{
public Slider BrightnessSlider;
public PostProcessProfile brightness;
public PostProcessLayer layer;
AutoExposure exposure;
void Start()
{
brightness.TryGetSettings(out exposure);
float savedBrightness = PlayerPrefs.GetFloat("BrightnessSliderValue", 0.5f);
BrightnessSlider.value = savedBrightness;
AdjustBrightness(savedBrightness);
}
public void AdjustBrightness(float value)
{
if (value != 0)
{
exposure.keyValue.value = value;
}
else
{
exposure.keyValue.value = 0.05f;
}
PlayerPrefs.SetFloat("BrightnessSliderValue", value);
PlayerPrefs.Save();
}
}
now I need to keep the brightness when changing scenes
that's the thing
then what that hell we've been talking about this whole time..
literally
make a Load method
and call it
when scene is changed
this goes inside a method
float savedBrightness = PlayerPrefs.GetFloat("BrightnessSliderValue", 0.5f);
BrightnessSlider.value = savedBrightness;
AdjustBrightness(savedBrightness);