#scenefield
1 messages · Page 1 of 1 (latest)
right
it's just a convenient way to store the name of one correctly
you will need to use the usual SceneManager methods to actually grab the Scene reference
Wouldt that bring us back to square one?
previously, you had no way to configure what scene you want through the inspector
this lets you identify the scene
the actual Scene object can only be retrieved if that scene is currently loaded
you can use that method to grab the Scene object if it has been loaded
I believe there is a distinction between the scene asset on disk
and the Scene type that you use with SceneManager
Okay, let me try this then, seperately.
sorry for delay, called for dinner
@torn pebble would this solution work?
private Scene Play;
void Update()
{
Play = SceneManager.GetSceneByName("Play");
if(Play.isLoaded)
{
SceneManager.MoveGameObjectToScene(gameObject,Play);
}
}
Yeah, although one thing to note: you can only get a scene by name if it's loaded
I'm a little fuzzy on that -- not sure why the field even exists, then..
you can call IsValid() on the Scene to check if it's a valid Scene
AH, thats why my thing got destroyed when i ran
if(Play.IsValid())
{
Play = SceneManager.GetSceneByName("Play");
}
```?
It just stopped existing
things don't get destroyed because they threw an error
Alright, im trying to transfer a value called spawnSpeed from the Main Menu scene to the Play scene. Code is
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
wait what?
you can either:
- put it in a
staticfield - call
DontDestroyOnLoad()on an object to prevent it from being destroyed when changing scenes
you got XY problem'd :p
Asking about your attempted solution rather than your actual problem
I already did that, the problem is that when the thing is in the DontDestroyOnLoad scene, it cannot modify another game object that is supposed to take the spawn speed variable and apply it
as for static, is this correct?
public static float spawnSpeed;
Right. That field is now associated with the class itself, instead of an instance of the class
Anyone can read it as ClassName.spawnSpeed;
whatever ClassName is
Ah, now im in actual pain that it was this simple
let me try the new solution
it's good to ask about what you want to do, rather than what you think you need to do (:
I spent like 90 minutes yesterday figuring out how to get full-screen post processing working in the URP in VR
Yeah, funny part is i know about the XY problem, never thought itd happen to me
I then realized that the effect I wanted looked horrible that way
and I just needed to change the brightness of a material when an objected appeared
So then thats how you got it working?