Search Unity

Multiplatform Runtime Level Editor

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

  1. TuncayCakmak

    TuncayCakmak

    Joined:
    Nov 26, 2018
    Posts:
    3
    Hi,

    i have bought your asset just recently and have to say that it is a really amazing package.

    I am struggling on a certain feature i would like to implement and hope you can give me some advices.

    What i would like to achieve is that i can insert "Ball-Prefabs" with the Level Editor which have a "Trigger Cube" and a "Moving Point". I have a script attached on the Balls which handles the action - If Trigger Cube entered via player - move ball (this ball is a children of the main Ball Prefab) to moving point. The "Trigger Cube" and "Moving Point" are Children of my Ball prefabs also the movable ball is a children.

    So what i would need to achieve is:
    1.) A own ObjectMap maybe called "Objects With Triggers and Moving Points" as an example. (I checked your documentation and created objectmaps as described. BTW i wrote you an Email and realised that your website and Email is down)
    2.) If one of these Objects are selected, a own GUI Window appear (like with objects with Color) , this GUI Windows allows you to select the Trigger Cube of the Object and the Moving Point of the Object (Both Children of the Object)
    3.) You can now place these Children in the level and if you Save and Load the Children are placed correctly

    What i tried is that i implemented a small script.
    I tried to modify the Code just to test something in the File LE_ObjectEditHandle.cs:

    I added this:

    if (Input.GetKeyDown("u"))
    {
    m_target = m_target.GetChild(1);
    }

    in line number 140

    so i was able to move the position of the cap of the barrel for instance, but after i have saved the level, the cap was still on the barrel. I assume it just loaded the prefab on the barrel position with the variation of the cap and did not save the position of the cap. So i need to somehow also save the position, rotation and scales of the 3 Children (Movable Ball, Trigger Cube, Moving Point). What i probably need is to somehow add a property like Variation or Color which is maybe called "With Trigger" or something. So if a drag an object with this property, it opens a new GUI Window where i can select the 3 Children (Movable Ball, Trigger Cube, Moving Point) and modify their positions etc. and save it. So if i load the level, the Parent Ball Objects get placed but also the Children will placed properly with the saved position, rotation, scale data.

    It would be really great if you have any idea how i can create easy to drag in and place Balls with a Trigger Cube and a Moving Point.

    I am trying to go through your code and understand it but many things are quite new for me and any hint would save me a lot of time to achieve the system with dragable prefabs which have the possibility to move children objects and save the positions, rotations,scales of the children objects.

    Thank you!!
     
    Last edited: Nov 23, 2021
  2. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    85
    I would look into serialization asset or use Unity'ss JsonUtility. Then create a script to hold all the position of your child objects to be serialized into a separate file.
     
  3. TuncayCakmak

    TuncayCakmak

    Joined:
    Nov 26, 2018
    Posts:
    3
    Thank you TonismoGames for your thoughts.

    I just thought its better to use what i already have with the MRLE scripts. So maybe i can just add additional properties to the Save/Load functions of MRLE?

    I have started to modify the LE_SaveLoad.cs, i have added this line for a first test:

    p_stream.Write(p_object.TestString); // Test

    in this function

    private static void SaveLE_Object(BinaryWriter p_stream, LE_Object p_object)
    {

    and this

    [SerializeField]
    private string m_TestString = "xyTest";

    public string TestString
    {
    get { return m_TestString; }
    set { m_TestString = value; }
    }

    into LE_Object.cs

    to somehow have the ability to save a string for the first test as an additional parameter to the objects. This is just to test everything and get a feeling for the code of MRLE. If i can modify the save load and save additional parameters in the the saved level file, dont you think it is a better way without writing new save and load scripts? As the next step i would try to clone the ideas of Objects with Colors/Variations to Objects with modifyable Children. So if you load a level, every Object with modifyable Children will have additional positions, rotations and scales for the Children and in the edit mode there will be a own GUI Windows to pick the Childrens you want to move around? Do you think this is a good way to go?

    Best
     
  4. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    85
    I see the problem with modifying the LE API is that when the developer updates the asset ,you could run into errors. There is an OnLoad/OnSave event that already saves everything to binaries. What you can do is add additional script to collect all the childrens positions and rotation then serialize that to another file. Here is something I added without modifying LE API.
    upload_2021-11-24_14-6-28.png
    I created my own Runtime Editor script with these call backs registering on start.
    upload_2021-11-24_14-8-24.png
    When OnSave is called,I collect all the LE byte arrays locally then open up a file browser
    The file browser will return the path where I want to save the map file to
    You can get this free Simple File Browser on the Asset Store
    upload_2021-11-24_14-13-44.png
    I use a zipdotnet to save all of my objects into a single zip. You can just use File.WriteAllBytes() method instead
    The CustomMeshObject is a MonoBehavior script I made to holds all the positions and rotations and any extra data outside of what is supported by LE
    Serializer is an APi from Serialization on the Assets Store. You can use Unity JsonUtility instead.
    Reason I dont use JsonUtility is because it is not thread safe and I save everything using another thread.
    JsonUtility is a lot easier to use though,it can serialize anything.
    To load,you can just do the opposite
     
  5. Neurolog

    Neurolog

    Joined:
    Oct 19, 2018
    Posts:
    7
    First off this is a phenomenal asset. Been very happy with the asset and the few changes I've been able to make so far.

    I am interested in click to place as well- in particular I'd like to have users click the item in the UI, the preview show up on the mouse without holding the mouse button down, then the user can either click to single place or click and drag to place multiple instances in a grid (using the 3d grid snap placement).

    For example, if they draw a 3x3 grid box, it places 9 of the prefab in the grid. Reading the implementation of placeobject and updatenewobjectdraganddrop, I can't seem to find where it is being told to place on mouse button release, or where it is showing the preview only while the mouse button is held. Any advice on how to tackle such a modification or where to find those aspects? I'll keep looking through the documentation in the interim. Thanks!
     
  6. dmenefee

    dmenefee

    Joined:
    Oct 14, 2019
    Posts:
    77
    Hello. The website with docs and demos appears to be down with a database error.
     
  7. TuncayCakmak

    TuncayCakmak

    Joined:
    Nov 26, 2018
    Posts:
    3
    Thank you so much! I will go through your advices and let you know how far i came. Best
     
  8. Zenithin

    Zenithin

    Joined:
    Jun 7, 2016
    Posts:
    34
    Get the online link up! Website is down how do I read docs!!
     
  9. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    85
    There is offline doc in the asset
     
  10. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    85
    You can implement this yourself through another script or use third party asset for grid instancing. You just have to add LE_Object component to objects being spawned.
     
  11. Neurolog

    Neurolog

    Joined:
    Oct 19, 2018
    Posts:
    7
    Took a little messing around but got it up and running. Thanks!
     
unityunity