Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Save objects position rotation in play mode

Discussion in 'Scripting' started by NRayta, Oct 18, 2021.

  1. NRayta

    NRayta

    Joined:
    Sep 6, 2021
    Posts:
    8
    So I have a positioning system and I need to save the rotation and position of my objects that I place in real time. What the problem I'm facing right now is that I place a gameobject then change its rotation & position then I unselect it but when I select it again the position rotation changes, I need to autosave it's position & rotation.
     
  2. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    So let me get this clear, you place a game object in play mode? Then change it's rotation and position in play mode? I'm a bit confused on what you just said

    EDIT: Wait, so do you mean you want to save all the new positions in your scene after you leave play mode. Eg. If an object was at (50,1,50) then got moved to (20,1,20) in play mode. You want to save those changes in the editor after leaving play mode?
     
  3. NRayta

    NRayta

    Joined:
    Sep 6, 2021
    Posts:
    8
    Sorry let me describe more on what I'm trying to achieve, I have an environment and in play mode I place objects in the environment (2d placement system, like how sims works) and those objects are movable meaning I can change their position, rotation & scale; all in game mode. Then when I deselect this object(say I go to choose another object to place) and select it again all the changes I made previously goes back to their original position. Again all in play mode.
    Now, what I want is these changes that I made to be saved in play mode, so when I select the object again it won't go to its original position.
    I have a save & load system for the scene itself but its useless in this case.
     
  4. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    So do you move these objects in the play mode, if yes I haven't really ever done something like this so I'm kinda unsure on this one. Sorry I couldn't help