Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiplatform Runtime Level Editor

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

  1. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Yes! You the man!! Thanks :)
     
  2. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    @FreebordMAD Thanks for the response!

    We had two problems with the save, the first we didn't realize how to call save without using a button. We wanted to call save from code. We solved that by simply calling the button pressed event from code as if the user had pressed saved. The other issue we had was that we didn't realize that the save function call back did everything for you. We were trying to manually find the data we needed to hand into the SaveCurrentLevelDataToByteArray. Once we figured out that all we had to do was subscribe to the OnSave event and then call the save button clicked event we were golden.

    It might be good to add a save call that doesn't use the button. The rest is our fault for cracking open your code and misinterpreting how the system worked.

    Thank you for the help, and also thanks for the undo redo feature!
     
    FreebordMAD likes this.
  3. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    I just found the bug and already dealt with it. My second problem is solved. One last problem. How can I make a GUI which can access the data in the folder, search all the save data in the folder, show them on the GUI and load them? I'm not good at programming and I don't know a thing about how to get this done, so could you teach me about this step-by-step? This is my last big problem. Thank you.
     
  4. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Great thanks for sharing your code with us! You have helped a lot in the development and support of the MRLE!
    In the version v1.30 TerrainData.SetHeightsDelayLOD is already used automatically if the Unity version is at least 5.2.2.
     
  5. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I have attached some classes to this post.
    UtilityPlatformIO: for the sake of simplicity the MRLE version of this class is stripped down and contains only what is needed. The version attached to this post is my full version used in my other games. It will spit errors on Samsung Smart TV and requires code in the Visual Studio project for Windows Store Apps (tell me if you also need this code, which platforms do you plan to release on?). The full version of this class has a GetFileNames method, which allows you to see all files in a folder.
    LE_GUIWindowPopupFileSelection: unfortunately, my game still uses MRLE v1.01 and therefore this script will not compile. Read through it and see how GetFileNames is used.

    To create a new popup you have to do the following:
    1. Take a look at these classes: uMyGUI_PopupTexturePicker, uMyGUI_PopupText, uMyGUI_PopupButtons, uMyGUI_Popup.
    All these classes derive from each other and add new functionality.
    2. Take a look at the Popup_TexturePicker_Root and Popup_Text_Root objects in the LE_ExampleEditor scene.
    3. See how the objects from step 2 are linked in the PopupManager object with the uMyGUI_PopupManager class.
    4. Now I hope you know how the popup system works. It is really simple. If you have any questions don't hesitate to ask!
    5. Build your own popups. Create a class named uMyGUI_PopupFilePicker. Let it derive from Popup_Text_Root use the UtilityPlatformIO.GetFileNames method (attached script) to show some files to pick and allow entering a file name in your popup.
    6. Create the popup UI in the scene and attach your popup script to it. Link your popup to the PopupManager object.
    7. Call in script something like this:
    Code (CSharp):
    1. uMyGUI_Popup popup = ((uMyGUI_PopupFilePicker)uMyGUI_PopupManager.Instance.ShowPopup("FilePicker"))
    2.                                 .SetPicker((string p_selectedFileName)=>
    3.                                 {
    4.                                     ... use the p_selectedFileName here to save or load the file
    5.                                 })
    6.                                 .SetText("Select File", "Click on the file which you want to load.")
    7.                                 .ShowButton("back");
    If you still have more questions, then feel free to ask again! I think it would be better for you to learn how to code the popups that you need. I can guide you through the process. Additionally, with your further questions I can improve this HowTo until it is good enough to be published in the documentation of the MRLE
     

    Attached Files:

  6. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    Hi, thanks for the reply.
    I plan to release my game to PC and smart phone platforms, so It's ok to use this GetFileNames method, but after I watched the code, I think it's a little complicated for me and I don't know how to let this "p_path" be the floder I want, in other words ,I don't know how to use it.
    Code (CSharp):
    1.     public static string[] GetFileNames(string p_path, string p_filter, string p_removeString)
    2.     {
    3. #if UNITY_PLATFORM_IO_NOT_SUPPORTED
    4.         Debug.LogError("UtilityPlatformIO: GetFileNames: not supported on this platform!");
    5.         string[] files = new string[0];
    6. #elif UNITY_METRO && !UNITY_EDITOR
    7.         string[] files;
    8.         if (OnGetFileNames != null)
    9.         {
    10.             System.Collections.Generic.List<string> fileList = new System.Collections.Generic.List<string>();
    11.             fileList.AddRange(OnGetFileNames(p_path));
    12.             // filter
    13.             p_filter = p_filter.Replace("*", "");
    14.             for (int i = fileList.Count-1; i >= 0; i--)
    15.             {
    16.                 if (!fileList[i].EndsWith(p_filter))
    17.                 {
    18.                     fileList.RemoveAt(i);
    19.                 }
    20.             }
    21.             files = fileList.ToArray();
    22.         }
    23.         else
    24.         {
    25.             Debug.LogError("UtilityPlatformIO: GetFileNames: OnGetFileNames was not inserted from VS code!");
    26.             files = new string[0];
    27.         }
    28. #else
    29.         string[] files = System.IO.Directory.GetFiles(p_path, p_filter);
    30. #endif
    31.         for(int i = 0; i < files.Length; i++)
    32.         {
    33.             files[i] = System.IO.Path.GetFileName(files[i]).Replace(p_removeString, "");
    34.         }
    35.         return files;
    36.     }
    Unfortunately, right now I can only write and understand very simple codes like this: (this very simple script is my solution to my second problem, but it works :D)
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine .UI;
    4. using LE_LevelEditor .Example ;
    5. using LE_LevelEditor.Core;
    6. using LE_LevelEditor .UI ;
    7.  
    8. public class NameTheSaveData : MonoBehaviour {
    9.    
    10.     public InputField Saveinput0;//this input field let the user can give his map a name;
    11.     public Button Save0;//click to save the map;
    12.     public GameObject  Nonamepopup0;//if there is no name, then this popup will show and says that you must give the map a name;
    13.     public ExampleGame_Editor  Levelobject;
    14.     public LE_GUIInterface Saveevent0;
    15.  
    16.    
    17.     public void OnclickSave () {
    18.  
    19.             if (Saveinput0.text == null )
    20.             {
    21.                 Nonamepopup0.SetActive (true );
    22.             }
    23.             else {
    24.                 Levelobject .LEVEL_FILE_NAME = Saveinput0 .text ;
    25.                 Saveevent0 .OnLevelSaveBtn ();
    26.             }
    27.        
    28.     }
    29. }
    30.  
    I can create GUIs on my own, and scripting is my real problem. To write the script about loading, I may do like this :
    1. Attach the UtilityPlatformIO class to any game object. (of course I can do this)
    2. Let my script use GetFileNames method.(How it works? How to use? And how to write?)
    3. Let these file names list on my GUI, and users can select it.(1.How to let these names list on the GUI? 2.the number of all files is uncertain. How should I create the same number of "buttons"(or input fields? or something else?) and let them selectable?
    4. When user select any file, the Level_File_Name will change to that name.
    5. After press the load button, then do LE_GUI_Interface.OnLevelLoadBtn().
    If this should work, then I can do phase 1, 4 and 5, but I can' do 2 and 3. Can you help me write this little script ? Thanks again for your Patience.
     
  7. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    @musou0 : I will write a full tutorial about the file selection. You are not the first person asking, so I think it's time to do it. However, I cannot tell you when it will be done. Probably in the middle of the next week...

    I have published my first demo video for the multiplatform runtime level editor! Any feedback is appreciated!
     
    ilmario likes this.
  8. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    Hi,
    I just bought your asset and it's great !
    As I am an artist and not a developer, I have a small question regarding the camera setup.
    I would like to use my own custom main camera instead of the default one when the user clicks the button 'PLAY'.
    I am not talking about the initial camera used to setup the scene but the one with the starting position.
    Could you please point me to the right direction on how I can change this ? Tnx.
     
  9. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    I'll be waiting for your tutorial.

    However if you make an update to the example scenes and add these functions, then I think everyone will be greatful about this... Nearly every game will need a main menu, and save and load multiple data files, right?
     
    Last edited: Dec 5, 2015
  10. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm glad you like it!

    In the LE_ExampleGame scene you will find a game object (prefab) called Camera Relative Controls. This object contains the player capsule and the camera. All scripts for the player movement and camera control are in this object. You can simply replace the whole thing with any third party character controller. The only thing that you will have to do is to link the player game object to the PLAYER property of the ExampleGame_Game script attached to the GameLogic object.
     
  11. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I will see what I can do next week.
     
    Last edited: Dec 5, 2015
  12. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29

    Thanks a lot for your support it works now !!!
     
  13. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    Hi
    Currently the save functionality is saving the game locally (level.txt). However I would like to save the game on my server. I searched this forum for explanation and even downloaded the example -> LevelUploadMadSnowboarding.zip. Unfortunately I wasn't able to implement this in the demo. It would be nice to have clear steps on how to implement this for non-developers. A simple unity scene example with just save and load functionality (with associated php and sql files) would be great. Because currently I don't know where to start. Your help would be greatly appreciated. Thanks
     
  14. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm sorry to say this, but without programming knowledge, it is impossible to do this. I would need to code everything for you...
    I'm looking for freelance work. I could do this for you. However, I need more information before I can tell you how much I would need to charge.
    Do you have a server?
    If yes, does your server support PHP?
    If yes, do you have something like MySQL and phpMyAdmin installed on your server?
     
  15. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    My hosting account supports php and mysql. This is not the problem. I just want to know on how I can save your demo game to my server. Which scripts from your assets can I update in order to save the demo game into my server instead of my local disk (as it's currently doing by default). Saving the level as a text file into the server directory is also good for me.
    I just need the steps and which files I need to update. Because it's was mentioned on your asset that one can save and load games from the server. That's why I am checking if you have a specific example or tutorial somewhere I can use.
     
  16. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Ok, I see. I have mentioned this in the description, because it is possible, but it is not a feature of the MRLE. The only tutorial that I have so far is the one that you have already found:
    http://forum.unity3d.com/threads/mu...any-one-interested.250920/page-4#post-2233288
    If you want, then I'm motivated to improve it. If you don't understand something, then ask a precise question and I will help you.

    However, code needs to be changed and written in C# and PHP to make it work. You have to setup a SQL database on your server. It would take me at least 20-50 hours of work to make a generic solution that could be used by any game. I have written one myself for my game Mad Snowboarding, but it is tailored for my game. What is included in the support of the MRLE Asset Store package is the consulting of the step by step development of your saving code. However, as I said before, it would be too much work for me without payment if I would send you code tailored to the needs of your game.

    Nevertheless, if you want we can start working on your solution. Let us as start with Step 1 (Save the byte arrays). Are you able to change ExampleGame_LoadSave so that it saves and loads from two files instead of one?

    [EDIT:] before we start you should tell me exactly how your game should work. How will the level listing work, does it support images, ranking, sorting, etc... Who can upload levels? Who can change levels? Who can upload updates to levels? etc...
     
  17. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    As I am just doing for a hobby and experimenting, it would be interesting to start with saving your existing demo game into a server. That's all. Nothing special just saving the level.txt file into a server (i.e., www.exampleserver.com/mydirectory). That would be good enough for me.
     
  18. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    @FreebordMAD is there any way to easily turn the level editor on and off? we've tried turning off all the editor game objects but the events are still hooked up so whenever we click it modifies the terrain.
     
  19. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    @CYBERDAD :
    @musou0 : I hate to say this, but I will start some time critical contracted work now, therefore I will still give support, but I cannot implement any new features in the next weeks. Both of you have requested full features, that not only need to be developed, but also tested. In the next few weeks I will have no time for that, but I will do it as soon as I have some time.
    So that everybody else knows it, those are the postponed features:
    - save/load file selection
    - simple server upload demo/tutorial for PHP/MySQL

    There are multiple ways to do it:
    1. Disable the TG_TouchGestures object or hack the corresponding script (exists only on runtime).
    2. Hack IsInteractable in LE_GUI3dBase or overload it in LE_GUI3dTerrain (pass false if you want the editor to be disabled).
    Please tell me if one of the solutions worked for you.
     
  20. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    FreebordMAD likes this.
  21. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    So it will take more time and looks like I have to do something else instead of just waiting.
    I will working on adding art resources and waiting for your good news.
    Thanks again for your support.
     
    Last edited: Dec 9, 2015
    FreebordMAD likes this.
  22. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    Hey just wanted to say we updated the package and are super happy with the undo redo! Awesome feature, makes it so players can build with much more confidence! Thanks
     
    FreebordMAD likes this.
  23. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Hey, uhm. simple question: i want to let the basic snap to grid cube always float in the air. so that it instantiated at.. lets say Y 20. how could i do that? i tried it with grid offset y20 but that seams to be wrong
     
  24. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    You could create a cube, move it to the right y coordinate, scale it on x and z axis and remove its renderer. Your grid cubes would snap to this invisible cube. Does this solve your problem?
     
  25. FreebordMAD

    FreebordMAD

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

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Thanks! But that would mean that i can not place something underneath it, right? I actually want to place sone bridge tiles, you know?
     
  27. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I'm not exactly sure what you want to achieve. Could you please upload some screenshots or gifs of the desired behaviour?
     
  28. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    no problem, so i made this small mockup:
    bridge.png

    1. shows my my current status. no problems to achieve this.
    2. shows what would happen if i do it the reccomended way. that leads to a "dead" area underneath the bridge where i can not place anything
    3. is what i want to achieve, so that i can still place something under the bridge
    4. is the result i want :)

    thanks :)
    edit: some more thoughs about this:
    i know i could just set/activate the translation to "is movable on Y axis" (currerently i only use X and Z) but then i have to always drag the bridge part from the ground up. and you could also build a bridge tile on the ground which is what i want to avoid. the bridge tile should always ne at Y:20 and not changeable
     
    Last edited: Dec 13, 2015
  29. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I see, but I think this should be easy. Simply use a different prefab for the bridge. In this prefab move the bridge to 20 on the Y axis. This way, if you place this bridge prefab it will snap to 0 on the Y axis, but its visuals (and colliders) will be on Y:20, because of the offset inside the prefab. Do you think this will work?
     
  30. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    so i did the following
    - created a blank gameobject on XYZ 000
    - put on this a LE Object script with the same settings as the GridBasedCube Example but translation only to the XZ axis
    - inside the gameobject i placed a 1x1 cube and set his Y value to 10
    the good thing is: it now floats in the air
    the bad thing: the handles are still at Y:0
    leveleditor_prefabfly.gif
     
  31. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I see :)
    Would it be exactly what you have asked for if the handles would be at the center of the game object?
    [EDIT:] this is easily done with some code, but only for scaling and moving. Rotating would be difficult. Which rotation axis work for your bridge?
     
    Last edited: Dec 16, 2015
    Der_Kevin likes this.
  32. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Yes, exactly,
    Thats perfect. I dont need the rotation since the road/bridge rotate automatically to the right position of the sorounding tiles:

     
    FaberVi likes this.
  33. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    The only thing that needs to be done is to move the handle object up to the center of the bridge when it is created in the LE_Object. You could try to do it yourself. Otherwise, I will send you some code, but I'm not sure if I will find some time before Christmas...
     
  34. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    @FreebordMAD Hi, I just found that the undo button is pressed by press the button "z". Where can I change the control settings?
     
  35. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    totaly fine. i wanted to try it but didnt achieve anything. i can wait. would be great if you can find some time one day. but iam also on holidays now, so take your time! merry christmas!
     
    FreebordMAD likes this.
  36. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
  37. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    By the way... Just out of curiosity...
    Iam adding 120 elements right now to the level editor and for this i have to:
    - render 120 icons
    - set up every object (which is pretty fast to be honest, the only thing thats taking time is to link the right thumpnail/image)
    - and then drag and drop it 120 times into the.. I forgot the name.... The thing where you enter your level objects ;)

    Is there a faster way? :D
     
  38. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    There is no faster was to link the objects in the object maps, but you don't need to render any icons or link them yourself. Just create and setup your new object. Then link it in an object map. The object map inspector will tell you that there is an icon missing. Click the render icon button and it will be generated and linked for you.

    Marry Christmas!
     
    Der_Kevin likes this.
  39. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    hey, thats cool. should have asked before i rendered all the icons :D
    i just have a problem with the rendering. i think its more unity related but maybe you know whats up
    leveleditor_prefab_icon.gif

    so the problem is, that the icon gets rendered from the backside. i guess because the prefab & model preview is also from the backside.

    when i rotate the prefab - doesent matter to what degree, it still gets rendered from the wrong side. is there a way to fix that? i guess the easiest way is to rotate the fbx file directly in a 3d program. but maybe there is a way unity can do this?
     
  40. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    and! another problem ;)
    when i change the height of the UI Rect Transform from the ObjectLeafPrefab from 48 to 120, this happens:
    leveleditor_gapbug.gif
    there is a big gap in the beginning
    when i change it back to 48, the gap isnt there?
    leveleditor_gapbug2.gif
     
  41. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Below you will find some code that will give the move handle of the Cube object an offset of 5 units on the Y axis.
    Code (CSharp):
    1.  
    2. if (m_editMode == LE_EObjectEditMode.MOVE && name.EndsWith("Cube"))
    3. {
    4.       m_editHandle.transform.localPosition = Vector3.up * 5f;
    5. }
    This code goes below the line 749: m_editHandle.OnTransform += OnTransform; (in v1.30) of the LE_Object script.
    Simply replace Cube in EndsWith("Cube") with the name ending of your bridge object. You could also add a new ending like "HandleOffset". This code works if your object is not scaled. Also, rotating would not work well this way.

    You can add an empty game object to your prefab's root, then add the visuals inside this object. Rotation of this object should be visible in the preview.


    I will take a look at your UI problem now.
     
  42. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    The problem is that my system (uMyGUI_TreeBrowser) expects that the category nodes (InnerNodePrefab) have the same height as the object nodes (LeafNodePrefab). In your case you have changed the height of the LeafNodePrefab, but not the height of the InnerNodePrefab prefab.
    Is it possible for you to use the same height?

    [EDIT:] I have reworked the uMyGUI_TreeBrowser class. Different heights for category and object nodes are possible now. Apply the following code in the uMyGUI_TreeBrowser class to fix your problem:
    Code (CSharp):
    1.         // replace this method
    2.         public void BuildTree(Node[] p_rootNodes, int p_insertAt, int p_indentLevel)
    3.         {
    4.             if (m_innerNodePrefab != null && m_leafNodePrefab != null)
    5.             {
    6.                 List<InternalNode> new_nodes = new List<InternalNode>();
    7.                 float minY = 0;
    8.                 float currY = m_nodes.Count >= p_insertAt && p_insertAt > 0 ? m_nodes[p_insertAt-1].m_minY : 0;
    9.                 for (int i = 0; i < p_rootNodes.Length; i++)
    10.                 {
    11.                     if (p_rootNodes[i] != null)
    12.                     {
    13.                         GameObject nodeGO;
    14.                         bool isInnerNode = p_rootNodes[i].Children != null && p_rootNodes[i].Children.Length > 0;
    15.                         // instantiate prefab
    16.                         if (isInnerNode)
    17.                         {
    18.                             // inner node
    19.                             nodeGO = (GameObject)Instantiate(m_innerNodePrefab);
    20.                         }
    21.                         else
    22.                         {
    23.                             // leaf node
    24.                             nodeGO = (GameObject)Instantiate(m_leafNodePrefab);
    25.                         }
    26.                         // get element size
    27.                         RectTransform nodeTransform = nodeGO.GetComponent<RectTransform>();
    28.                         float elementSize = nodeTransform.rect.height;
    29.                         // propagate data via SendMessage (must be done before parenting to guarantee that the object is active)
    30.                         if (p_rootNodes[i].SendMessageData != null)
    31.                         {
    32.                             // check if object is active
    33.                             if (!nodeGO.activeInHierarchy)
    34.                             {
    35.                                 Debug.LogError("uMyGUI_TreeBrowser: BuildTree: node has SendMessageData set, but instance is inactive! SendMessage call will fail! Make your prefab active!");
    36.                             }
    37.                             nodeGO.SendMessage("uMyGUI_TreeBrowser_InitNode", p_rootNodes[i].SendMessageData);
    38.                         }
    39.                         // save in local structure
    40.                         InternalNode node = new InternalNode(p_rootNodes[i], nodeGO, p_indentLevel);
    41.                         new_nodes.Add(node);
    42.                         // setup foldout behaviour of inner nodes
    43.                         if (isInnerNode) { SetupInnerNode(node); } else { SetupLeafNode(node); }
    44.                         // move to the right position
    45.                         currY = SetRectTransformPosition(nodeTransform, currY, elementSize, p_indentLevel);
    46.                         // calculate max y position to resize this rect transform
    47.                         node.m_minY = nodeTransform.anchoredPosition.y - elementSize;
    48.                         minY = node.m_minY;
    49.  
    50.                         // notify listeners
    51.                         if (OnNodeInstantiate != null) { OnNodeInstantiate(this, new NodeInstantiateEventArgs(p_rootNodes[i], nodeGO)); }
    52.                     }
    53.                 }
    54.                 // move nodes behind the insert index
    55.                 if (p_insertAt < m_nodes.Count)
    56.                 {
    57.                     float moveDist;
    58.                     if (p_insertAt == 0)
    59.                     {
    60.                         moveDist = minY;
    61.                     }
    62.                     else
    63.                     {
    64.                         moveDist = minY - m_nodes[p_insertAt-1].m_minY;
    65.                     }
    66.                     UpdateNodePosition(p_insertAt, moveDist);
    67.                 }
    68.                 // add new nodes to list
    69.                 if (p_insertAt < m_nodes.Count)
    70.                 {
    71.                     m_nodes.InsertRange(p_insertAt, new_nodes);
    72.                 }
    73.                 else
    74.                 {
    75.                     m_nodes.AddRange(new_nodes);
    76.                 }
    77.                 // resize rect transform (e.g. to allow scrolling if scroll rect is the parent)
    78.                 if (m_nodes.Count > 0)
    79.                 {
    80.                     RTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,  Mathf.Abs(m_nodes[m_nodes.Count-1].m_minY - RTransform.rect.yMax - m_offsetEnd));
    81.                 }
    82.             }
    83.             else
    84.             {
    85.                 Debug.LogError("uMyGUI_TreeBrowser: BuildTree: you must provide the InnerNodePrefab and LeafNodePrefab in the inspector or via script!");
    86.             }
    87.         }
    Code (CSharp):
    1.         // replace this method
    2.         private float SetRectTransformPosition(RectTransform p_transform, float p_currY, float p_size, int p_indentLevel)
    3.         {
    4.             // parent and move prefab
    5.             p_transform.SetParent(RTransform, false);
    6.             Vector2 pos = p_transform.anchoredPosition;
    7.             pos.x += p_indentLevel*m_indentSize;
    8.             p_currY -= m_offsetStart;
    9.             pos.y += p_currY;
    10.             p_currY -= m_padding + p_size;
    11.             p_transform.anchoredPosition = pos;
    12.             return p_currY;
    13.         }
    [EDIT:] I have made some more changes to fix padding and start/end offsets. Tell me if you use them (they are all 0 by default), then I will send you more code. The code above works fine without padding and offsets.
     
    Last edited: Dec 28, 2015
  43. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Thanks!
    the UI fix works perfect!
    for the handle thing i have to upgrade to 1.30 first (i am still on 1.22 ;)... ) but i assume its also perfect. thanks!
     
    FreebordMAD likes this.
  44. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    You don't need to update, it will also work with 1.22, just search for the code.
     
  45. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    wanted to have the undo stuff anyway, was easie to update. and: everything works perfect (ui and handle transform. thanks!)
    so, another question :D
    i switched to orthographic cam since my game has also a isometric perspective. so rotation doesent work anymore. which is not bad, but, can i sowehow change the right mouse button so that i can drag the camera around? like i would use the QEAD keys?
     
  46. FreebordMAD

    FreebordMAD

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

    What do you mean with "so rotation doesent work anymore"?
    How have you switched to orthographic? Did you use the gizmo for that?
    Or any methods in LE_LevelEditorMain like OnCameraPerspectiveSwitchToOrthographic?

    To move the camera with the right mouse button you could replace the code inside the RotateCamera method of LE_LevelEditorMain with the code below:
    Code (CSharp):
    1. void LE_IInputHandler.RotateCamera(Vector3 p_fromScreenCoords, Vector3 p_toScreenCoords)
    2. {
    3.     ((LE_IInputHandler)this).MoveCamera(p_fromScreenCoords, p_toScreenCoords);
    4. }
    5.  
    Also take a look at the LE_InputDeviceMouse class. It is only 80 lines long and describes how the mouse input is handled.
     
  47. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    so, just tested it again and its weird :D
    when i start the mapeditor/game with an ortho cam, it doesent work (hold the right mouse button to rotate)
    when i change it when the game is still running to perspective and then back to ortho cam, the rotation also works with the ortho cam.

    all i did was to change the cam projection mode, nothing more. but its not so important since i dont want rotation at all :)
    your snippet works perfect! thank you very much!

    do you have any news for the bug where you zoom in/out (camera) when you scroll threw the level object list with the mouse wheel :) ?
     
  48. musou0

    musou0

    Joined:
    Dec 2, 2015
    Posts:
    16
    @FreebordMAD

    Hi,I got a bug to report. When playing the "Editor" scene and try to build something , there is a little chance to trigger a bug: When dragging an object icon on terrain, there is a little chance to let the object model "sticking" on the mouse cursor and I can't place the model on the terrain. Any way to fix this?
     
    Last edited: Jan 9, 2016
  49. PLLART

    PLLART

    Joined:
    Jan 9, 2016
    Posts:
    2
    Hello!

    First of all, congrats for this wonderful editor! I am using this editor since a few months, I am very pleased with it and I would like to ask you about something. It may sound basic but I didn't found any easy solution yet. Is there an easy way to edit, at runtime, a child of an LE_Object the same way we would with its parent? Let's say I have "car" parent object (with the LE_Object script on it) and I drag and drop it on my scene using your editor. Now, how can I edit the child parts of that car? Currently, children object with LE_Object can be edited, but if I save my work and then load my scene again, the objects are loaded back to their prefab default state and all the work is lost. I would really appreciate if you could help me with that!
     
  50. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    The editor expects the camera to be perspective on start. It should be switched to orthographic in code before the first frame. However, since you don't need the rotation anyway, there is no need to change anything here.

    I'm sorry, but I had no time to solve this issue yet. Is this important for you?

    Could you please post a screenshot? What exactly do you mean with "object model "sticking" on the mouse cursor"? Do you still see the object icon instead of the 3d prefab? Or is the prefab not projected onto the terrain?

    Great to hear that!

    Unfortunately, this is not possible yet. Don't you get errors in a console every time you try to load a level with nested LE_Objects?
    You could add some functionality yourself to allow this. Are you familiar with coding? You could store the changes that you have applied to your child prefabs in the level's meta data.