0
\$\begingroup\$

I have a Unity program where all the GameObjects are created programmatically in C#, so there's nothing to see in the Scene window unless I hit play. I can hit pause and change the settings for a camera, but those changes are all discarded when I exit playmode.

What do I have to do to make the MODIFIED values the new, PERMANENT ones?

\$\endgroup\$
  • \$\begingroup\$ If your camera is being spawned programmatically, then you'd need to apply your desired parameters at spawn time inside the script that spawns it, no? Or have I misunderstood where this camera is coming from? \$\endgroup\$ – DMGregory Aug 25 '18 at 20:12
  • \$\begingroup\$ The GameObjects are spawned programmatically, but the camera is the default one that was part of the scene when I created the new project. \$\endgroup\$ – Bitbang3r Aug 26 '18 at 22:34
0
\$\begingroup\$

I have a Unity program where all the GameObjects are created programmatically in C#

...

the camera is the default one that was part of the scene when I created the new project.

...then not "all the GameObjects are created programmatically," if there's at least one (the camera) that's present in the scene before you run. These details matter to the answer, so be sure to always be specific about your situation and what you need.

In this case, once you've modified the camera in the editor's play mode to have the settings you want, you can click on the gear icon at the top-right of the component inspector and choose Copy Component.

Copy Component menu in Unity

After you exit play mode, click on the gear again and select Paste Component Values to overwrite the camera's settings with the ones you copied.

If you need to do this with multiple components, or multiple objects, you can also save the object as a prefab, then apply the changes back to the prefab to save them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.