Search Unity

Multiplatform Runtime Level Editor

Discussion in 'Assets and Asset Store' started by FreebordMAD, Jun 10, 2014.

  1. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I will now explain how to save levels to a database, so that your community can share them using your server. You will find some scripts attached to this post. These scripts will not compile, they are taken from my game Mad Snowboarding. I have added them to show you how it works in Mad Snowboarding. However, you will need to modify them to make it work. Also, I will not miss the chance to say: help Mad Snowboarding and vote for it on Steam Greenlight!
    Don't hesitate to ask if you need more help.

    1. Save the byte arrays
    Multiplatform Runtime Level Editor comes with an example implementation of saving the level byte arrays to single file or to copy them to the clipboard in the Webplayer (ExampleGame_LoadSave.cs).
    To allow level sharing over the internet I have saved the data and the meta byte arrays in different files.
    For example: a file named [level name].lvl1 for the level data byte array and a file named [level name].lvl2 for the meta bytes.
    This setup has the advantage that you can download the .lvl2 files and load the level icons from them. This allows you to create a level listing showing the level icons and any further information that you have saved in the meta data.
    One more important point is that you have to use a zip tool! Compress your levels, it will save up to 70% data volume!
    Check the LevelLogicLoadSave class in the attached archive to see how all of this works in Mad Snowboarding.

    2. Allow your users to upload the zipped byte array files
    Simply use the WWW class to upload files, here is the example code taken from Mad Snowboarding:
    Code (CSharp):
    1.  
    2. WWWForm wwwForm = new WWWForm();
    3. ...
    4.  
    5.                 // read file that needs to be uploaded from disk
    6.                 WWW localFileWWW = new WWW("file:///" + pFilePathes[i]);
    7.                 yield return localFileWWW;
    8.                 if (!string.IsNullOrEmpty(localFileWWW.error))
    9.                 {
    10.                     Debug.LogError("WebDatabase: WebCall: could not upload file. Open file error: " + localFileWWW.error);
    11.                     s_lastUploadedFilesContent = null;
    12.                     pCallback(null);
    13.                     yield break; // stop the coroutine here
    14.                 }
    15.                 // add the bytes of the file to a wwwForm
    16.                 wwwForm.AddBinaryData(pFileNames[i], localFileWWW.bytes, pFilePathes[i], "text/plain");
    17.                 s_lastUploadedFilesContent[i] = localFileWWW.text;
    18.  
    19. ...
    20. WWW www = new WWW(...url..., wwwForm);
    21. yield return www;
    22.  
    On your server you have to save the uploaded files to disk (on the server) again. Some example PHP code:
    Code (CSharp):
    1. // get your uploaded files with something like:
    2. $_FILES['lvl1'] and $_FILES['lvl2']
    3.  
    4. // do some security checks (valid file names etc...)
    5.  
    6. // save files to server's hard drive with something like this
    7. move_uploaded_file($_FILES['lvl1']['tmp_name'], "./levels/" . $_FILES['lvl1']['name'])
    8.  
    Now save the uploaded level data name, file location, etc. in your database.

    3. Allow your users to get a list of your levels
    You now need one more PHP script to fetch a list of uploaded levels. Here is how I get the levels for Mad Snowboarding:
    Code (CSharp):
    1.  
    2. $sort_mode = GetPostSafe('int1');
    3. $offset = GetPostSafe('int2');
    4.  
    5. if ($sort_mode == 0)
    6. {
    7.     $orderString = " ORDER BY plays DESC";
    8. }
    9. else if ($sort_mode == 1)
    10. {
    11.     $orderString = " ORDER BY downloads DESC";
    12. }
    13. else if ($sort_mode == 2)
    14. {
    15.     $orderString = " ORDER BY timestamp DESC";
    16. }
    17. else if ($sort_mode == 3)
    18. {
    19.     $orderString = " ORDER BY (plays / downloads) DESC";
    20. }
    21. else
    22. {
    23.     die("ERROR: UNKNOWN SORT MODE '" . $sort_mode . "'!");
    24. }
    25.  
    26. // send only parts of the table according to the requested window
    27. $levels = DB::query("SELECT * FROM " . LEVELS_TBL . $orderString . " LIMIT " . strval(intval($offset) * 20) . ", 20");
    28. echo "OK";
    29. foreach ($levels as $level)
    30. {
    31.     echo "#" . $level['level_name'] . ";" . $level['size_mb'] . ";" . $level['trick_level_time'] . ";" . $level['width'] . ";" . $level['length'] . ";" . $level['downloads'] . ";" . $level['plays'];
    32. }
    33.  
    4. Allow your users to download levels
    The simplest solution here would be to place the uploaded levels in a public folder that can be accessed through the internet. For example, if a player wants to see the level icon of level "level_123", then he would download the file at "www.yourserver123.com/levels/level_123.lvl2". Once the file is loaded the level icon can be extracted and shown to the user. If the player wants to play this level, then he also has to download the "www.yourserver123.com/levels/level_123.lvl1" file.

    5. Make a listing with sort options
    As you have seen in point 3 you can add some sort options and then show levels to your users. Add a more levels button to get the next group of levels.

    Summary
    1. zip the data and meta byte arrays to save up to 70% space (see attached UtilityCompression.cs)
    2. save the data and meta byte arrays to separate files (see attached LevelLogicLoadSave.cs)
    3. implement a PHP/MySQL upload script on your server
    4. use the WWW class to upload levels
    5. implement a PHP/MySQL level listing script on your server
    6. use the WWW class to get the sorted level listings
    7. display the level listings (download level icons, etc...). Access the publicly available uploaded level files once the user needs to see the icon of a level or wants to download it (WWW class again)
     

    Attached Files:

    Last edited: Aug 3, 2015
  2. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    I am sure everyone will love this. I hope this package really takes off for you. I will pick it up soon, likely this week depending on a few factor but soon. I'm sold :) thanks for the pre sales support. Sooo important!
     
    FreebordMAD likes this.
  3. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    Alright so I purchased it. :) One thing I would add for clarity is that 4.3 users should open the shaders and copy paste your example code into them, rather than replacing...as unity loses track of them. I would assume I am the only 4.3 user left in the world at this point though lol.

    I would add, that the above walk through makes sense on level loading from a server and I now know enough to figure it out. It might take me 2 days to build the GUI and get it all working. So I would add, if you threw together a package for $35 I would gladly buy it and save myself all that time. :)
     
    FreebordMAD likes this.
  4. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I will add the copy shader code thing to my post above! Thanks for the info!

    Hey, normally I would put something together for you, but I'm getting married in a week and getting married is a lot of stress ;) so unfortunately, I have no time right now...
     
  5. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    congrats! And no rush ;-) lol. I actually have a lot of other things still to do, and this feature won't be in version 1 of the game anyways. Do let me know if you plan to get around to it, if not I will eventually.
     
    FreebordMAD likes this.
  6. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    Is "ObjectPrefabResourcePaths" not really being used in LE_ObjectMap.cs? I was looking to do some dynamic loading of objects using runtime importers and was hoping I could just:
    ROOT_OBJECT_MAP.SubObjectMaps[1].SubObjectMaps[0].ObjectPrefabs[0].***Do Stuff***
    ...in LE_GUILevelEditor.cs

    (Like adding my own LE_Object.cs's at runtime, add perhaps using a www call for the icon path?) Does this seem plausible?
     
  7. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    LE_ObjectMapInspector sets the values of ObjectPrefabResourcePaths. Therefore, you have to select the object map that contains your LE_Object to get the ObjectPrefabResourcePaths updated. This usually happens automatically at the moment where you add the object to a map. Since ObjectPrefabResourcePaths contains relative resource paths (e.g. "Objects/Buildings/BuildingRundown") you can simply load them from your server. Does this answer your question?

    [EDIT:] and yes of course you can add or remove objects at runtime from the LE_ObjectMap
    [EDIT2:] don't forget to call LE_GUIWindowRight.Rebuild to reflect the changes in the UI. You can also take a look how this is solved for the terrain (you don't need to rebuild the whole right window). Search for m_doRebuildTerrainTab to find the terrain code.
     
    Last edited: Aug 8, 2015
  8. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    I'm sure the big day (gettin' hitched) is almost here, if not already here - so no rush on this question.

    Any chance there is a easy path to remembering a custom terrains trees?
    I was reading the docs and it is great to be able to work with an existing terrain. But what about all the trees, rocks, grass etc I have on it? Does that get kept? Can I move those in the editor if they have colliders? etc.

    http://www.freebord-game.com/index....ime-level-editor/documentation/custom-terrain

    Also I just saw your http://www.freebord-game.com/index.php/dev-tools/quality-loader

    is this already in use in the MrLE?
     
  9. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    As you can see in one of the demo scenes, MRLE works with Unity terrain details and trees. However, modifying and saving those is not yet implemented. Since I want to keep MRLE as simple as possible, so that players can handle it without having developer background, this feature is not high on the priority list and will not be included in the September patch.

    No, it is not part of MRLE, but my game Mad Snowboarding uses it in combination with MRLE.
     
  10. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Hi, I purchased MRLE a few weeks ago and have just gotten around to using it for my latest project.

    I have been reading the documentation, however I might be missing something but I cannot find an example of how you add MRLE to an existing project.

    I would like to see a simple step by step showing what prefabs need to be dragged into a scene and what settings need to be applied to add the MRLE functionality...

    Apologies if this is covered somewhere in the documentation, if it is, please point me to where it is, thanks in advance!

    Really excited to start using MRLE in my projects! :)
     
    Ony likes this.
  11. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    MRLE has no global settings. Also the integration depends on your game. My suggestion for you is to import the MRLE including the example assets and scenes. Then open the best matching example scene, select everything and copy paste it to your game's scene. You can also add the objects of your game to one of the example scenes. The only thing that needs to be done are the 'Terrain' and 'Gizmo' layers. However, you don't need to use them, if you don't use the terrain functionality or the axis gizmo. Warnings will tell you exactly what needs to be done once the scene is started.

    I have written an entry in the backlog for that, as soon as I have time I will add this to the documentation. If you want to add the MRLE to an existing scene step by step, then you would need to do the following:
    1. create a new empty game object
    2. add a LE_LevelEditorMain script to the empty game object
      • assign the ROOT_OBJECT_MAP property (see example object map _RootObjectMap)
    3. add a LE_ConfigLevel script to the game object with the LE_LevelEditorMain script
    4. add a LE_ConfigTerrain script to the game object with the LE_LevelEditorMain script
      • add the LE_BrushProjector prefab to the scene and assign it to the Brush Projector property
      • assign the brush textures to the Brushes property
      • assign the Terrain Texture Config property (see example config TerrainTextureConfig)
      • assign all heightmap and alphamap resolutions and sizes
    5. create a custom UI and use the LE_GUIInterface (see this doc link) or copy paste UI from the example scenes
    6. create a custom editor logic and use the LE_EventInterface (see this doc link) or copy paste from the example scenes
    All properties have a tooltip just hover with the mouse over the properties in the inspector.
    There are tons of warnings that should be fired when you setup something wrong. You will find further explanations in them.
    Post here again if something is unclear, this will allow me to create an easy to understand documentation page about this.

    Unfortunately, I will be in the woods for the next two weeks without a PC. Therefore, even if I find some decent internet connection on some treetop, I will have no PC to check the code and the assets... So again for everybody:

    I'm on holiday for the next two weeks. I will not be able to give you support during this time. Post your questions I will answer them later. I'm sorry for any inconvenience...
     
    Last edited: Aug 17, 2015
  12. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Hi FreebordMAD, thank you so much for the reply, this is exactly the info I require, I will have a play about over the next couple of days and let you know!

    Enjoy your two weeks in the woods! :)

    All the best!
     
  13. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    I noticed the save and load level code used the "#" to as a delimiter between the terrain data and the meta data when saved to a file. How would we know the "#" would never appear by chance in the terrain data? If it did by chance appear, it would corrupt the load process.
     
  14. Centripetal

    Centripetal

    Joined:
    May 31, 2013
    Posts:
    96
    Ah, I see it's encoded to Base64 at the top of ExampleGame_LoadSave.Save method.
     
    FreebordMAD likes this.
  15. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    I just tried the package in Unity 5.2 it seems like a lot of stuff is broken.

    Dungeon level editor doesn't even have a way to play in game mode. Nice to see this added though.

    Example editor (first you have to create "Terrain" layer on layer 28, which I am sure is in the docs). Then I create a basic scene, new terrain and char controller, save it and hit play. All i see is blue.

    ok, just messed with build settings scene orders and now example editor seems to work but why does the example game have to be on id 1 rather than 0? In fact why aren't you using Application load (str)? rather than id? Or doing a debug message or a check if the level it is trying to load is the level already loaded etc?

    Some stuff here to polish for sure.
     
  16. wjpeters

    wjpeters

    Joined:
    Jan 3, 2013
    Posts:
    16
    Hi,

    Is it possible to bypass the preview drag&drop? What i want is to have a scroller with objects. Just like in your demo scene. But instead of clicking on a object and then drag it from the preview image into the scene. I want to drag it directly from the scroller like the HayDay store scroller (see pic below). I've got my scroller working and i can drag the icons but i can't get any object placed in the scene. Only the last object item in the scroller is working. I've been working on this for the past two days but i can't get it to work. Any suggestion on how to set this up?

    -- cheers
     

    Attached Files:

  17. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    First of all, thanks for purchasing MRLE to both of you!

    It would be great if you could give me some more details here. I know that the automatic icon generator has some problems with Unity 5.1 and 5.2. These problems will be fixed in the upcoming v1.3 release.

    This is by design. The dungeon editor should show that you can use the Multiplatform Runtime Level Editor directly in your game. It is not only a standalone editor, but it can be built into your existing games. For example, to allow you to move objects in your dungeon, while playing in first person perspective.

    I'm sorry I don't exactly understand the problem here. Do I get it right that you have fixed it already?

    If you import the MRLE into an empty project, then you will see some install instructions on the first start. You will see that my system expects a certain ID order. You are right, I could also use strings or check if a level can be loaded. I will add some checks in the upcoming patch.

    Unfortunately, I'm on holiday right now I have no PC here to check my code. I can send you some code examples in the beginning of the next week. For now I can only send you some links from the docs, but you probably have found them already...
    Doc page: http://www.freebord-game.com/index.php/multiplatform-runtime-level-editor/documentation/custom-ui
    Interesting events/methods:
    LE_GUIInterface.Delegates.IsObjectDragged
    LE_GUIInterface.Delegates.SetDraggableObjectState
    LE_GUIInterface(.EventHandlers).OnObjectSelectDraggable
     
    wjpeters likes this.
  18. wjpeters

    wjpeters

    Joined:
    Jan 3, 2013
    Posts:
    16
    Thanks for your response. Would be really great if you can send me some code examples when you get back from holiday.
     
  19. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    Whats the best way to get the selected object name in the example editor for a GUI I am making? I want to have a little "about object" info about each item that the user can place in the scene.
    I have dug into the LE_Object script but cant seem to "locate it" at runtime.

    I am using Playmaker so I must be able to have the vairable as a public one to access it. ;) Itried setting

    private LE_GUI3dObject m_GUI3dObject = null;
    to
    public LE_GUI3dObject m_GUI3dObject = null;

    Which would allow me to access the name but it throws a error every frame.

    Thanks for any help you can offer.

    I love the Asset so far and am very satisfied with it.

    Kevin
     
  20. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Below the options to get the name and resource path of the selected prefab in the UI are explained. If you want to get the instance that is currently selected in the scene take a look at this post.

    SOLUTION 1:
    This is the right solution from the software engineering perspective, you would not need to hack anything for it. Just add the following MonoBehaviour to your scene (file is also attached).
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using LE_LevelEditor.UI;
    4.  
    5. public class SelectedObjectNameGrabber : MonoBehaviour
    6. {
    7.     public string SELECTED_OBJECT_RESOURCE_NAME = "";
    8.     public string SELECTED_OBJECT_RESOURCE_PATH = "";
    9.  
    10.     private void Start()
    11.     {
    12.         LE_GUIInterface.Instance.events.OnObjectSelectDraggable += OnObjectSelectDraggable;
    13.     }
    14.  
    15.     private void OnDestroy()
    16.     {
    17.         if (LE_GUIInterface.Instance != null) { LE_GUIInterface.Instance.events.OnObjectSelectDraggable -= OnObjectSelectDraggable; }
    18.     }
    19.  
    20.     private void OnObjectSelectDraggable(object p_obj, LE_GUIInterface.EventHandlers.ObjectSelectDraggableEventArgs p_args)
    21.     {
    22.         SELECTED_OBJECT_RESOURCE_NAME = p_args.ObjPrefab.name;
    23.         SELECTED_OBJECT_RESOURCE_PATH = p_args.ResourcePath;
    24.         Debug.Log("Object Selected: name='"+p_args.ObjPrefab.name+"' path='"+SELECTED_OBJECT_RESOURCE_PATH+"'");
    25.     }
    26. }
    27.  
    With Playmaker you can simply access SELECTED_OBJECT_RESOURCE_NAME or SELECTED_OBJECT_RESOURCE_PATH.


    SOLUTION 2 (this is a hack):
    If you set m_GUI3dObject to public in the LE_LevelEditorMain class, then you should be able to access the name of the currently selected object with this code:
    Code (CSharp):
    1. string selectedObjectName = FindObjectOfType<LE_LevelEditorMain>().m_GUI3dObject.SelectedObject.name;
    2.  
    3. // code with some error checking
    4. string selectedObjectName = "Nothing selected";
    5. LE_LevelEditorMain lvlEditor = FindObjectOfType<LE_LevelEditorMain>();
    6. if (lvlEditor != null && lvlEditor.m_GUI3dObject.SelectedObject != null)
    7. {
    8.     selectedObjectName = lvlEditor.m_GUI3dObject.SelectedObject.name;
    9. }
    I don't know exactly how you would put it into Playmaker (never had a chance to work with it). Is this what you have tried?

    SOLUTION 3 (this is a hack):
    In the LE_GUIInterface_uGUIimpl class (or LE_GUIInterface_uGUIimplDungeon class) you will find the following code line:
    Code (CSharp):
    1. LE_GUIInterface.Instance.OnObjectSelectDraggable(selectedObj, selectedResourcePath);
    This line tells the editor which object is selected. The instance selectedObj is the LE_Object that you are looking for. You could write some code here to pass this object to the place where you need it (e.g. a public property).


    ALSO take into account that in the later solutions the name would look like 'Objects/Buildings/BuildingRundown', which is the full resource path of the object. Only the first solution provides you the name of the prefab.


    Please don't hesitate to ask again, please also tell me if it worked for you.


    I'm glad to hear that! It would be super awesome if you could say this in a short Asset Store review ;)

    p.s.: @wjpeters: I'm working on some code now
     

    Attached Files:

    Last edited: Oct 29, 2015
    wjpeters likes this.
  21. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I was able to implement the drag&drop directly from the listing, but it didn't work well, because some events were missing. Therefore, I have added this functionality to the next version. Please send me an e-mail to info@freebord-game.com (it would be great if you could include your invoice nr.). I will then send you the updated files needed for smooth drag&drop directly from the object tree browser.
     
    wjpeters likes this.
  22. wjpeters

    wjpeters

    Joined:
    Jan 3, 2013
    Posts:
    16
    Thank you for taking your time to answer my question!!

    I've mailed you my invoice nr.
     
  23. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    You're welcome! I have sent you a .zip archive with the changed scripts. Thanks to you MRLE has a great new feature ;)
     
    wjpeters likes this.
  24. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    Ok Thanks very much for the help and for the Script. :) I ended up using Option 1.

    It worked perfectly but I am trying to get the object selected that has already been in the scene. Not the object in the scroller menu. I want to be able to get the selected object in the scene that has the move, rotate, and scale cursors on it after selecting with the hand. (After being placed in the scene.) Sorry I was not more clear on this. After I get the in scene game object name that is selected, I am going to have a small 3d menu pop up above the object (if a key is pressed) and you can change variables attached to an attached FSM to that object. (IE; Physics, weight, drag etc)

    I did need this script and will be using it to give the user more info on what each object does before they put the item into the scene.

    anyway to get the in scene game object that is selected?

    Thanks again and Yes I have already made a nice review in the asset store. You deserve it for such a nicely packaged tool.
     
    FreebordMAD likes this.
  25. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Good that it works for you.

    Indeed, at the moment LE_GUI3dObject is the only place where you would be able to get the selected object in the scene. However, I don't want users to hack in the system for such general tasks as getting the selected object. In other words, you found a case of a missing event. I will add it now and include in the upcoming patch. Please send me an e-mail to info@freebord-game.com with your invoice number. I will send you the changed scripts as soon as they are done.

    Thanks, nice to hear that ;)
     
  26. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    445
    I love this guy ^ Thanks a million.

    Thanks again. Not a big hurry. I have Sooooo much to do before launch in a couple weeks.
     
  27. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Here is a short tutorial script, just in case that someone will search again for a way to get the selected object instance in the scene (if you need to get the selected prefab in the UI take a look at this post). Works since v1.22 (currently waiting for approval).

    Add the following MonoBehaviour to your scene (file is also attached).
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using LE_LevelEditor.Events;
    4.  
    5. public class ObjectSelectionTest : MonoBehaviour
    6. {
    7.     public string SELECTED_OBJECT_RESOURCE_PATH = "";
    8.  
    9.     private void Start()
    10.     {
    11.         LE_EventInterface.OnObjectSelectedInScene += OnObjectSelectedInScene;
    12.     }
    13.  
    14.     private void OnDestroy()
    15.     {
    16.         LE_EventInterface.OnObjectSelectedInScene -= OnObjectSelectedInScene;
    17.     }
    18.  
    19.     private void OnObjectSelectedInScene(object p_obj, LE_ObjectSelectedEvent p_args)
    20.     {
    21.         SELECTED_OBJECT_RESOURCE_PATH = p_args.SelectedObject!=null ? p_args.SelectedObject.name : "";
    22.     }
    23. }
    With Playmaker (or anything else) you can simply access SELECTED_OBJECT_RESOURCE_PATH or implement the handling in different way inside the OnObjectSelectedInScene function.
     

    Attached Files:

    wjpeters likes this.
  28. eXntrc

    eXntrc

    Joined:
    Jan 12, 2015
    Posts:
    21
    I'm about to purchase this library, but I have one unique ability that I need to support that is fairly uncommon and I wanted to ask if it was possible.

    My game needs to support loading custom models and textures from disk and not from asset bundles. I'm looking at libraries like Runtime Model Importer to enable that capability.

    How can I support saving levels with those custom objects? Is there any way to include custom data as part of the save process?
     
  29. eXntrc

    eXntrc

    Joined:
    Jan 12, 2015
    Posts:
    21
    Well, I went ahead and bought the package assuming that we'll find a way to support custom models. But right now I'm having trouble getting the basic editor to work at all.

    I imported the package with everything turned on. Then I set the Editor as the main scene and included the other ones in the order specified. At runtime I got warnings that the Terrain and Gizmo layers (28 and 29) did not have names. I gave them the names I was told to give them. Now the editor is running, but whenever I click the Create Terrain button the game crashes.

    The stack dump shows it's all in unmanaged code.

    > UnityPlayer.dll!00007ff90170ef25() Unknown
    UnityPlayer.dll!00007ff901b066ad() Unknown
    UnityPlayer.dll!00007ff901b06508() Unknown
    UnityPlayer.dll!00007ff9017f6b7e() Unknown
    UnityPlayer.dll!00007ff901717973() Unknown
    UnityPlayer.dll!00007ff90171639f() Unknown
    UnityPlayer.dll!00007ff901736a5a() Unknown
    UnityPlayer.dll!00007ff90174e98f() Unknown
    UnityPlayer.dll!00007ff901748d95() Unknown
    UnityPlayer.dll!00007ff901748ac0() Unknown
    UnityPlayer.dll!00007ff901819bc2() Unknown
    UnityPlayer.dll!00007ff901d98eda() Unknown
    UnityPlayer.dll!00007ff901d99c12() Unknown
    UnityPlayer.dll!00007ff9030312dc() Unknown
    UnityPlayer.dll!00007ff902fe9e19() Unknown
    UnityPlayer.dll!00007ff902fe9d13() Unknown
    UnityPlayer.dll!00007ff902fe9b3d() Unknown
    UnityPlayer.dll!00007ff902fe8329() Unknown
    UnityPlayer.dll!00007ff902fe8298() Unknown
    UnityPlayer.dll!00007ff903099c80() Unknown
    UnityPlayer.dll!00007ff90309a369() Unknown
    UnityPlayer.dll!00007ff90309a3f8() Unknown
    UnityPlayer.dll!00007ff90309e533() Unknown
    threadpoolwinrt.dll!00007ff953e73f4d() Unknown
    threadpoolwinrt.dll!00007ff953e7a9e7() Unknown
    kernel32.dll!00007ff960fa3c02() Unknown
    ntdll.dll!00007ff963630c14() Unknown

    The last message in the output window is:

    'HoloTest.exe' (Win32): Loaded '[[redacted]]\bin\x64\Debug\AppX\System.Reflection.TypeExtensions.dll'.
    'HoloTest.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded '[[redacted]]\bin\x64\Debug\AppX\System.Reflection.TypeExtensions.dll'. Loading disabled by Include/Exclude setting.
    IsNormalized (normal)

    (Filename: C:\buildslave\unity\build\Runtime/Geometry/Plane.h Line: 74)

    I should note that this is a Windows 10 UWP app and not a Windows 8.1 app. Also, I'm running Unity 5.2.2f1.

    Any ideas what I'm doing wrong?
     
  30. eXntrc

    eXntrc

    Joined:
    Jan 12, 2015
    Posts:
    21
    Next I tried including a default terrain by setting the Custom Default Terrain property of the script to a prefab. Then I got the following errors which may be related to the crash above:


    UnityEngineProxy.dll!UnityEngineProxy.InternalCalls.TerrainData_Get_Custom_PropTreeInstances(object self) Unknown
    > Assembly-CSharp.dll!LE_LevelEditor.UI.LE_GUI3dTerrain.ApplyDefaultTerrainData(UnityEngine.TerrainData p_terrainData) Line 335 C#
    Assembly-CSharp.dll!LE_LevelEditor.UI.LE_GUI3dTerrain.GetDefaultTerrainDataDeepCopy() Line 315 C#
    Assembly-CSharp.dll!LE_LevelEditor.LE_LevelEditorMain.InitializeDefaultTerrain(LE_LevelEditor.LE_ConfigTerrain p_LEConfTerrain) Line 437 C#
    Assembly-CSharp.dll!LE_LevelEditor.LE_LevelEditorMain.Initialize_InFirstUpdate() Line 341 C#
    Assembly-CSharp.dll!LE_LevelEditor.LE_LevelEditorMain.Update() Line 497 C#
    Assembly-CSharp.dll!LE_LevelEditor.LE_LevelEditorMain.$Invoke29(long instance, long* args) Unknown
    UnityEngine.dll!UnityEngine.Internal.$MethodUtility.InvokeMethod(long instance, long* args, System.IntPtr method) Unknown
    [Native to Managed Transition]
    UnityPlayer.dll!00007ff901c9609e() Unknown


    Program: ...40.00.Debug_14.0.23019.0_x64__8wekyb3d8bbwe\MSVCP140D_APP.dll
    File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\include\vector
    Line: 1232

    Expression: vector subscript out of range


    Program: ...les\Apps\HoloTest\HoloTest\bin\x64\Debug\AppX\UnityPlayer.dll
    File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\include\vector
    Line: 1233

    Expression: "Standard C++ Libraries Out of Range" && 0


    The error was in ApplyDefaultTerrainData at treeInstances

    private void ApplyDefaultTerrainData(TerrainData p_terrainData)
    {
    p_terrainData.hideFlags = m_defaultTerrainDataPrefab.hideFlags;
    p_terrainData.detailPrototypes = m_defaultTerrainDataPrefab.detailPrototypes;
    p_terrainData.treePrototypes = m_defaultTerrainDataPrefab.treePrototypes;
    HERE --> p_terrainData.treeInstances = m_defaultTerrainDataPrefab.treeInstances;


    Unhandled exception at 0x00007FF90144FE8B (ucrtbased.dll) in HoloTest.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
     
  31. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    If you have some library (Runtime Model Importer) that can load models on runtime, then it is possible to do that. However, you would need to write a lot of cutom code for this. One example could be:
    1. [Create] Make some UI and allow user to load models from file
    2. [Create] Make a prefab for this new object on runtime
    3. [Create] Add this prefab to some level object map
    4. [Create] Refresh UI to show the new object in the drag and drop listing

    5. [Save] Write the model files to the levels meta data
    6. [Save] Save the level as usual

    7. [Load] Load the level's meta data first
    8. [Load] Load all custom models and create prefabs for them
    9. [Load] Add loaded prefabs to level object maps
    10. [Load] Change the load level code and make the system check if no built in prefab exists
    11. [Load] If the prefab that is being loaded is not included in the Resources, then find it in the prefabs created from the meta data

    This is the summary of what needs to be done and it is only a suggestion. We can talk about every step in more detail once you got Multiplatform Runtime Level Editor working on your system.
    [EDIT:] here is something about loading custom objects that I have discussed earlier.


    Unfortunately, I have no computer with Windows 10 to test on and I cannot reproduce this problem with Windows 8.1. Could you please try to simply remove the line which causes the problem? If it is only this line, then the only difference that should happen is that trees would disappear on load.
    I have worked with Unity 5.2.2 to fix some issues last week. MRLE seems to have no big problems with it. Therefore, I think that Windows 10 must be the problem.
     
    Last edited: Nov 2, 2015
  32. eXntrc

    eXntrc

    Joined:
    Jan 12, 2015
    Posts:
    21
    Commenting that line out allowed it to progress further but it did not resolve the problem. Now I can get into the editor but the terrain is not visible. I made sure the prefab I created for Default Terrain has a texture and is on the Terrain layer. Am I misunderstanding this? Should Default Terrain be linked to an instance instead of a prefab? If so, how should I hide it?

    Honestly, this isn't a great solution because even if could get the default terrain working I still can't load any levels. As soon as I attempt to load the "Pure Terrain Editor" level it fails again with:

    Program: ...40.00.Debug_14.0.23019.0_x64__8wekyb3d8bbwe\MSVCP140D_APP.dll
    File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\vc\include\vector
    Line: 1216

    Expression: vector subscript out of range

    This appears to be very similar to the same issue you commented on here:

    http://forum.unity3d.com/threads/wi...el-load-vector-subscript-out-of-range.203381/

    Unfortunately changing the build to Master doesn't cause the problem to go away.

    I feel this is a a VC++ runtime issue, specifically MSVCP 14. Though obviously Windows 10 apps are compiled with Visual Studio 2015 and VC++ 14.


    I would like to continue this discussion offline because there are some sensitive details about the project and I also may be able to help you out. I'll try e-mailing you at your info@freebord-game.com address.
     
    FreebordMAD likes this.
  33. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I have sent you an email to your work email address.
     
  34. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    hey! quick question!
    do you have some kind of connected tile system in your assets?
    for roads for example? so that you have a road, drag it, and then it creates corners and crossing points automatically?
     
  35. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    So far only the snap object functionality is included. You can see how it works in the Objects tab under Level->Obstacles->Box Curve. After placing this object you will be able to attach other objects to it by clicking the plus icon in the scene.
     
  36. wjpeters

    wjpeters

    Joined:
    Jan 3, 2013
    Posts:
    16
    Hi there, i've got two questions.
    - Is it possible to use a grid where the objects can be placed on?
    - Can i place a object in the scene without a terrain or another object to snap on?
     
  37. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Grid object placement is possible. What exactly do you plan? Take a look in the demo: "Objects Tab->Level->Decoration->Grid Based"

    Yes, just create a new cube (in the GameObject menu in the Unity Editor) on runtime and you will be able to place objects on it. For trees (snap to terrain) you will need to set this cube's layer to Terrain, then you will be able to snap those to the cube.
     
  38. wjpeters

    wjpeters

    Joined:
    Jan 3, 2013
    Posts:
    16
    Thanks, i didn't look good enough at the grid based cube. That's exactly what i want :)
     
    FreebordMAD likes this.
  39. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I have implemented some feature request made in the last month, now the patch has been approved and is available for all of you. Here is the change log:
    Patch v1.22:
    FIX: icons rendered with the object map inspector had a gray background (instead of transparency) in Unity Pro
    FEAT: level objects drag&drop now works directly from the tree browser listing
    FEAT: optional random rotation on placement
    FEAT: added the OnObjectSelectedInScene event to LE_EventInterface
     
    wjpeters likes this.
  40. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Hey, got some more questions :)
    Is it possible to snap specific objects to each other without using a grid?
    Next question goes in the same direction: how can i prevent objects from overlapping?
    Is it possible to use a script on a placeable object? Something like to this and that when placed. Nothing compicated

    What i actually want to do is this:

    wallplacement.gif
    This is a wall placement script i did a while ago. You can find it here:

    https://www.dropbox.com/s/9xc4hidjkou77yo/dynamicwalls.unitypackage?dl=0

    But i want to reuse it for a racettack editor. So the tiles need to snap to each other and the tiles shouldnt overlap. Also some kind of fast/mass building would be reallygreat

    Thanks! :)
     
    Last edited: Nov 16, 2015
  41. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Take a look in the demo: "Objects Tab->Level->Obstacles->Box Curve".
    You can continue building the curve by clicking on the plus icon in the scene.

    For now this is only possible for objects with rigidbodies. For example, try to move a car inside some other object in the demo.

    You can write your own script and attach it to the level objects. Your script could check for overlapping objects and solve the collision. You can also register for object placed or moved events and solve all collisions there.

    This is not part of the MRLE yet.
     
  42. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    thanks, these answers help a lot. also just saw your previous posts with the "Objects Tab->Level->Decoration->Grid Based" and i thinks that was almost what i was looking for. thanks :)
    just asked all these questions because i recently bought another level editor asset and was pretty disappointed. so this time i just wanted to be sure :)
     
    Last edited: Nov 16, 2015
    FreebordMAD likes this.
  43. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    okay, after intensive testing of the demo i can say its great :D

    i have one last question:
    when i spawn the Objects Tab->Level->Decoration->Grid Based"
    the object can not be rotated. so its turned off for this object i assume. but if i turn it on, will the rotation also snap? so that i can only rotate it in 45° angles?
     
  44. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    This is not yet implemented, but you could simply add your own script. For example, you could enable rotation in the editor and create a script that would rotate your object to the closest valid rotation value once the mouse button is released.
     
  45. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    okay, thanks sounds reasonable. this would also work for specific objects only , right?
    so that you can rotate a cube for example only by 45° steps and another object the usual free rotation.

    and there is another thing which i thought of right now. is there a way to let the camera rotate around the focused object? i mean you have the focus button already but when you rotate it always rotates around the camera itself. would be a better usability i think
     
  46. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Yes, this is possible, just attach your script to the prefabs that need it and don't use it for the prefabs that should have the default behaviour.

    If you are on PC try Alt key + right mouse button in the demo or see the help menu
     
  47. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    :eek: sold! :)
     
    FreebordMAD likes this.
  48. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    just bought it and as good and as i expected :)
    so, i already have a question :D is there a way to turn off the "on-top-of-each-other-placement" of the grid cubes? so that i can not place them on top of each other but next to each other? i want to use this for road placement and i guess it would be weird if you can place 2 road tiles on top of each other :D

    and, i just write down what i would like to see in the future. its more a wish list so you can decide what you want to do with it :)
    1.) object multi selection like this:

    2.) precise snapping - like this:

    3.) mass placement - like this


    :) thats it ;)
     
  49. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm glad to hear that!

    You could use LE_EventInterface.OnObjectDragged event (see event doc page). You could disallow placement "on-top-of-each-other-placement" like it is done in this article. For example, just check the y value and allow only objects on the base level (below y == 5 or something like this). Would this solve your problem?

    Multiselection and object grouping is already on the list.

    I will put this on the list.

    This is a very advanced feature for grid editors, since MRLE is not a grid editor I fear it will take a lot of time until I will implement a feature like this. There are just too many other things that need to be done before that.
     
  50. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    hey, yeah, thanks! haven't read threw the docs yet but that looks exactly like what i was looking for

    sure, this is also not important for me i have to admit, just a nice feature. also i can see some problem with the drag and drop usability of the editor so its rather complicated and needs some time

    can i ask what features are also on the list or what is planed?