Search Unity

Saving changes made during a play session

Discussion in 'Wish List' started by reallyjoel1, Feb 2, 2009.

  1. reallyjoel1

    reallyjoel1

    Joined:
    Feb 2, 2009
    Posts:
    19
    I haven't found a way to make a change made during a play session permanent.

    It's really inconvenient to try and remember several tweak values, and then re-set them when you have exited the play-session.

    My suggestion is to add a button next to each variable in the Inspector when you are in a play session, that saves the current setting for that variable.
     
  2. careyagimon

    careyagimon

    Joined:
    Dec 20, 2007
    Posts:
    209
    One method, and this doesn't work for all set-ups, is to select the changed game-object and copy it, as in command-c. You can then hit stop and paste it back into the hierarchy and delete the old GO. This is handy for positioning things with gravity too.
     
    OddBloom and justkittenaround like this.
  3. reallyjoel1

    reallyjoel1

    Joined:
    Feb 2, 2009
    Posts:
    19
    The goal here is to increase workflow and usability for future relases, not find hacks around current issues.

    What you descibe might work to some degree, but it sounds like it will give problems with naming, and that could screw up scripts. It's also a bit clumsy.

    It's probably a smart thing to do while we're waiting for some official feature, but as I said, the goal is to make the application better.

    With that said, does anybody agree with my suggestion?
     
    Crzonga and (deleted member) like this.
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Theres a recorder script on the wiki somewhere.
     
  5. FragomirJagr

    FragomirJagr

    Joined:
    Feb 3, 2009
    Posts:
    12
    This dovetails nicely into the very issue I am having. I am writing a game. Further, I am writing a level editor for said game as a standalone application. So while I am in the level editor "Play" mode, I am making tons of changes using a typical drag and drop tool palette style interface. After I have completed dragging and dropping all the objects in the level, I wish to save my work out basically as a unity scene file, as the end result is a level which will be loaded by my game proper.

    Currently you cannot save out a scene file while in play mode... it was suggested i save out some form of metadata... but I have no idea how to turn unity objects into any kind of metadata. I have a ton of different prefabs I have constructed, etc.... but since I don't have access to the internals of the engine, how does one even begin to write out some kind of proprietary metadata......

    Anyway, it would be nice if I could add a "Save" button to my level editor GUI, and upon pressing said button, to save out a scene file. Further, it would be nice to be able to flag objects in the scene as "Do not save to scene"... as in my level editor I don't want to save the tool palettes, or the game building "canvas".
     
  6. DGuy

    DGuy

    Joined:
    Feb 7, 2007
    Posts:
    187
    Hi,
    I'm currently using Unity as the level builder for a simple 2D game I'm working on. I'm able to drag and drop prefabs, rotate them and toggling them between states using hot-keys I've defined, have them snap to an invisble hex grid, lock my 2D tiles to specific Z-depths (makes draging them around much simple), view their scripted animations, ... all while in edit, not play, mode. I then save the whole thing as a scene and load it up when needed.

    My suggestion would be to look into the following things:

    * ExecuteInEditMode

    * Gizmos

    * EditorClasses, specifically:
    • * MenuItem

      * Selection
    * Object.hideFlags, specifically the flags:
    • * DontSave

      * HideInHierarchy
    HTH
     
    zoran404 likes this.
  7. GargantulaKon

    GargantulaKon

    Joined:
    Jul 20, 2009
    Posts:
    3
    I am trying out Unity 2.5 (Trial) and it seems to be missing some important features. I searched this forum and registered just to chime in that this saving-after-stopping feature needs to be integrated into Unity eventually.

    I was moving a light into a perfect position while I was in Play mode. I could not figure out what was going on after stopping. I thought I had multiple lights in the scene or something. I then realized my settings are not saved after I stop the scene.

    The other Unity feature that is natively missing is exporting the terrain as an OBJ to accurately place a road within the terrain. I found a script through this forum, but this should be part of Unity itself.

    Terrain should start at 0,0,0 with the pivot right in the center. In addition, I want to be able to move all my height to a higher height without flattening since I want to go deeper, but the terrain starts at the lowest point.

    Big issue I have is that I want to view my terrain in full resolution, not have it dynamically change the number of polygons. I have my player settings set to Fantastic, but that does not change what I want.

    Other than that, everything is pretty good so far.

    The video tutorials need to be updated and shown in a higher res since I could not tell exactly what the teacher was doing when modifying the particle effects during one of the later videos. I also noticed that the "Import Settings" have moved to another section since Unity v2.5.1 is not shown in the videos.

    I love how I can import the Pro Standard materials into the trial version even though it is running in "Indie" mode. I am going to give Unity a try and then Torque 3D since I already have a license for TGE.

    Thank you for your help to everybody in this forum!
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sometimes it would be very nice to "snapshot" a certain change, I agree, and I hope they implement that at some point, but mostly it would be a huge pain if changes were saved by default.

    One of the main features of Unity is that the editor is extensible. The OBJ exporter script becomes part of Unity once you put it in your project--it's as native as it will ever be; parts of Unity are made with scripts like that, such as the terrain system.

    Terrains are put at 0,0,0 by default; you can move them wherever you like. You can't rotate terrains, so I'm not sure what difference it makes where the pivot is. Due to the way heightmaps are created, the pivot is naturally at the corner, and they can't move it now even if it's possible, since it would break all existing projects that use the terrain.

    --Eric
     
  9. GargantulaKon

    GargantulaKon

    Joined:
    Jul 20, 2009
    Posts:
    3
    Thanks Eric!

    I agree that changes should not be saved by default in case one wants to test different settings without ruining the default settings.

    When I said natively, I meant that it should be included by default when someone downloads the trail since it is essential to my design process. I am glad for you for creating it. I love it!

    When I said 0,0,0 I mean for the terrain center point to be centered by default, not at the corner, This is not a big deal, I can can transform 1000 units for X and Z axis in order to center a default settings terrain.

    Another issue I have is that I want to view my terrain in full resolution, not have it dynamically change the number of polygons I see as I zoom in and out and pan. I have my player settings set to Fantastic, but that does not change what I want. When I am in top view, it is updated to show in a higher resolution, which is better, but it goes away when I go back to perspective view.

    In addition, when I go to select a texture for my terrain (Edit Textures > Add Texture...), a nice small texture preview box is shown for half of the textures in the context menu, but the other half, the boxes do not appear. Is this a bug? The texture box appears when I select the texture before clicking on "Add". When editing the texture I can get a nice preview of the texture on the terrain in the background as well.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    UT is welcome to include it if they like, but I think most people don't need it. That's why the wiki exists. :)

    I don't think that's possible, since the point of the terrain system is to do just that. You can minimize it by setting the pixel error to 1 though.

    Not sure; what format are the textures that don't appear? I haven't seen that myself, though I usually use drag'n'drop rather than the context menu.

    --Eric
     
  11. GargantulaKon

    GargantulaKon

    Joined:
    Jul 20, 2009
    Posts:
    3
    Thank goodness for the wiki then and for you for sharing it!

    I only want the terrain to do so when in the editor. Where do I set the pixel error value?

    I attached the screen shot of what I am seeing. See how the last two columns are missing thumbnails?
     

    Attached Files:

  12. Tobbe

    Tobbe

    Joined:
    Jan 18, 2010
    Posts:
    5
    In reply to the original post I would really like a "tweak" mode. An additional play button that allows editing during playback would really help me in tweaking AI paths and animations amongst others.
     
  13. fngkestrel

    fngkestrel

    Joined:
    May 26, 2010
    Posts:
    1
    It's June 30th, 2010. Has there been any additional news on a save tweaked settings feature? I'm running into it now, and while most of Unity is a joy to work with, this is a pain.
     
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Does not exist unless you write own editor scripts for the purpose
     
  15. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
    Angry Ant has some editor scripts available here.
     
  16. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    @careagimon - you are the man. That is EXACTLY what I was looking for. Can't believe I overlooked that. Was about to call it quits.
     
  17. plasticarm

    plasticarm

    Joined:
    Nov 14, 2009
    Posts:
    7
    Not sure if anyone else mentioned this technique for saving the state of objects during runtime, but this is what I do.

    Create a prefab called "Level" (or whatever name you like)
    Parent all the objects you want to save under the "Level" game object.
    While the game is in play mode and you are ready to save your changes - Select the "Level" object and in the inspector hit "Apply".
    All the changes made to the game object "Level" will be saved to the prefab.
    When you stop the game, the objects will stay where they were when you pressed "Apply".

    This works better than copying and pasting the objects in the scene.
    Plus, it involves no scripts or anything.
    Trust me, this method works great.

    Search for my thread "Level Builder"
    That's the technique I use for building all my levels, and I haven't found any caveats yet.
     
    Last edited: Dec 17, 2010
    Alkann likes this.
  18. VCCGeek

    VCCGeek

    Joined:
    Nov 17, 2009
    Posts:
    89
    Plasticarm, here's one caveat: If you use that method, you can't use prefabs within that game object. If you don't need prefabs, I guess that's ok, but personally, I use prefabs incessantly. If I were to apply settings every time I tweaked something, it would screw things up royally.

    Not saying it's a bad idea -- just saying that there's a cost.

    Edit: this is also assuming that I'm reading what you're saying correctly. :)
     
  19. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    Hey plasticarm - question for you. Your suggestion is great and Im trying to do something very similar to your Level Builder. I'm trying to follow it and getting caught with one problem. I have a script that on function Start(), Instantiates a bunch of objects with their position and names. Then, a second script on Update() that scales and rotates all of those objects (~500 objects). I created the Prefab, and the first time I hit Play, copy all of the objects into the Prefab, and hit Apply. Everything looks great in the scene mode and my Prefab looks correct. Then, the next time I hit Play all of the objects are there, but the Scale and Rotation is all wrong (like the original script never ran). Any ideas? I'm only about 2 weeks into learning Unity, so I appreciate the help!
     
  20. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    Update: tried the Transform Saver that Angry Ant suggested. Still not working - I make all of the rotation changes and everything looks great in Edit mode. The second I hit Play all of the objects revert back to the original rotations from when they were Instantiated.

    Anyone have any ideas?
     
  21. JakeT

    JakeT

    Joined:
    Nov 14, 2010
    Posts:
    34
    Seems to have been related to the Animation setting. All of my models exported to FBX with blank animations. Removing the animations seems to have solved it.
     
  22. plasticarm

    plasticarm

    Joined:
    Nov 14, 2009
    Posts:
    7
    I forgot to mention...
    I also use a script called "Prefab Connection"
    that script is automatically added to each object that is instantiated. It automatically gets the original prefab attached to the component.
    There is a function of Prefab Connection that replaces the object with the prefab that it originated from. That way I also can restore any object to its original state.
    Does that make sense?
    I would upload the scripts I'm using, but the system is rather complex with reliance on other many other scripts. I'm working on simplifying it so It's easier for others to implement in their own proejcts.
     
  23. plasticarm

    plasticarm

    Joined:
    Nov 14, 2009
    Posts:
    7
    JakeT :

    I would suggest using the technique I mentioned above. Also, I forgot to mention the "Prefab Connection" script I attach to each object that is Instantiated.


    Code (csharp):
    1. @script AddComponentMenu ("Managers/Prefab Connection")
    2. /* //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    3.     Attach this script to keep a link to the original prefab in case it gets broken
    4.     Call ReconnectPrefab to Destroy this go and put the original back in.
    5.    
    6. */ //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    7. var prefab : GameObject;
    8.  
    9. function AddPrefabConnection( go : GameObject ){
    10.     prefab = go;
    11. }
    12.  
    13. @script ExecuteInEditMode()
    14. @ContextMenu ("ReconnectPrefab")
    15. function ReconnectPrefab(){
    16.     var myParent : Transform = transform.parent;
    17.     var go : GameObject = Instantiate(prefab, transform.position, transform.rotation);
    18.     go.transform.parent = myParent;
    19.     go.name = prefab.name;
    20.     go.AddComponent(PrefabConnection);
    21.     go.SendMessage("AddPrefabConnection", prefab, SendMessageOptions.DontRequireReceiver);
    22.     if(Application.isEditor){      
    23.         DestroyImmediate(gameObject);              
    24.     } else {       
    25.         Destroy(gameObject);
    26.     }
    27.     Debug.Log("Prefab was Reconnected");
    28. }
    Using the above script makes up for the fact that prefab connections are broken.
     
  24. Devin-Reimer

    Devin-Reimer

    Joined:
    Dec 14, 2009
    Posts:
    15
    I wanted to let everyone know that this has frustrated me so much over the years that I wrote a solution. It's called PlayModePersist and it is now available on the Unity Asset Store.
    While in Play Mode you simply select the components you wish to persist from the required GameObject(s) and then the moment you click stop, it persist all your changes. No need to copy and paste changes or anything like that.

    You can find it in the Unity Asset Store under extensions. For more information: http://blog.almostlogical.com/2011/01/11/playmodepersist-unity-asset-store/

    Let me know your thoughts.
     
  25. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
  26. Devin-Reimer

    Devin-Reimer

    Joined:
    Dec 14, 2009
    Posts:
    15
    @Neodrop I did try to get that to work a month ago with no luck. The important difference is PlayModePersist allows you to persist changes automatically without a need to copy and paste. Very easy to use.
     
  27. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    But not free ;)
    My code is open and it is a very-very easy to add this functionality in it.
     
  28. Devin-Reimer

    Devin-Reimer

    Joined:
    Dec 14, 2009
    Posts:
    15
    But yours is only "free" for non-commercial project. For only $10 you can use PlayModePersist on any project you like. Plus anyone who purchases PlayModePersist can view my source and make changes to it if they like.
    PlayModePersist goals easy and quick to use and lightweight.
     
  29. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Not correctly. Antares Project is absolutly free for any projects, except Antares.dll which are not present in standart Antares Project package.
     
  30. Devin-Reimer

    Devin-Reimer

    Joined:
    Dec 14, 2009
    Posts:
    15
    @Neodrop Thanks for correcting me on that, I thought that applied to the whole project.
     
  31. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    No doubt, your scripts are good. But our solutions differ.