Search Unity

Runtime Editor

Discussion in 'Assets and Asset Store' started by Vadim-Andriyanov, May 9, 2017.

  1. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Runtime Editor is the set of scripts and prefabs which help you to create scene editor, game level editor or build your own modeling application. It supports drag & drop, undo & redo and selectionapi. To implement user interface and core functions runtime editor use transform-handles, gizmos, save load subsystem and three controls: menu, virtualizing tree view and dock panels.

    forum-screenshot.png



    Out of the box it has six Views:
    • Scene View to manipulate objects in the scene.
    • Hierarchy View for displaying and manipulating the object tree.
    • Project View to manage assets and scenes.
    • Inspector View to display and edit object properties.
    • Console View to display information, warnings and errors.
    • Game View for the game.
    • Add More...
    The Runtime Editor has many ready-to-use property and component editors and it is relatively easy to create new ones. "Add Component" drop-down button allows you to add components at runtime. There are also several important dialogs included:
    • Save Scene Dialog.
    • Object Picker.
    • Color Picker.
    • Asset Bundles and Libraries Importer.
    • Manage Projects Dialog.
    List of Features
    • Position, Rotation, Scale Handles.
    • Grid, Box Selection, Scene Gizmo.
    • Transform Handles mobile & Google AR Core support.
    • Global & Local coordinates, Local & Center pivot point modes, Vertex & Grid snapping.
    • Gizmos for Colliders, Lights and Audio Sources.
    • Scene navigation, Orthographic & Perspective view.
    • Undo & Redo API.
    • Object selection API.
    • Object life-cycle Events.
    • Play & Edit mode.
    • Configurable Inspector.
    • Component & Material editors.
    • 16 Built-in property editors.
    • Add Component control.
    • Multiple Scenes and Cameras support.
    • Dock Panels & Windows Management.
    • Dialogs, Message Boxes, Confirmations.
    • Easy to extend with new windows.
    • Configurable Main & Context menu.
    • Fast Virtualizing Tree View for Hierarchy and Project windows.
    • Configurable Save & Load subsystem (almost no coding is required).
    • Easy to use Project API.
    • Static Assets, Asset Bundles and Dynamic Assets support.
    • Load assets on demand.
    • Multiple Projects support.
    Documentation

    Getting started:
    https://www.assetstore.unity3d.com/en/#!/content/64806

    Roadmap:
    • HDRP/LWRP support
    • ARCore support
    • Multiple components editing
    • OBJ, PNG Importer
    • Animation Recorder
    • Nodes Editor
    • Object Placement API
     
    Last edited: Mar 1, 2019
  2. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    This is one of the best unsung tools in the asset store. If promoted heavier, its success would probably skyrocket.
     
  3. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Great tool.
     
    Vadim-Andriyanov likes this.
  4. RonnyDance

    RonnyDance

    Joined:
    Aug 17, 2015
    Posts:
    557
    Hi Vadim,
    yeah finally a support Thread in the Unity Forums :)

    My question:
    I asked some time ago if its possible to save Scenes as Unitypackages or scene Files with your RuntimeEditor to be able to work on the scenes in the Unity Editor, after gamers created own levels with your RuntimeEditor.

    Our scenario:
    We want gamers to create their own dungeons and levels with your Tool but before adding the created Levels by the Community to the final game, our team should review them in the Unity Editor. After a Review from the Team the levels / scenes are added manually to the officiall game.

    I saw that you improved the saving a lot in 1.3. Is this now possible or is only save to file / text still supported?

    Cheers
    Ronny
     
  5. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Yes it is possible in version 1.3.2



    Regards,
    Vadim
     

    Attached Files:

    BackwoodsGaming likes this.
  6. Evasion4D

    Evasion4D

    Joined:
    Aug 8, 2013
    Posts:
    16
    Hi Vadim,

    Very good idea this forum

    As you did for the 1.2 to 1.3, it would be nice if you put the various improvements between the versions

    Good continuation

    Jean Michel
     
    Vadim-Andriyanov likes this.
  7. JacobK

    JacobK

    Joined:
    Jun 18, 2013
    Posts:
    20
    Hiya, I've used this a while back before RTSaveLoad was added and I remember it being pretty useful.

    However, since the "Build Resource Map" has been added, this is completely useless to me now. As far as I can tell, build resource map creates an asset in the Resources folder with a reference to every single asset in the entire unity project. Meaning if you've got say, a couple of texture libraries or sound effect libraries in your project, they will *ALL* get included in the build. Or more realistically in my case... unity won't even let you build, it'll just crash out.

    Oh, and when I click the play button, unity will lock up for a few minutes, climb to about 10gb of ram use, and eventually unfreeze. In an empty scene, with just RuntimeEditor in.

    Oh, and if I even select the ResourceMap file in Assets\Battlehub\RTSaveLoad\ResourceMaps\, unity will lock up for a few minutes.

    Is there a way to use this without RTSaveLoad? Adding a single asset via the "expose to editor" seems to force the whole resource map to be generated, with a counter value in the 6 digit ranges ._.


    This is painfully designed - I get the idea behind it, but I don't think the average user will realise the implications of having a reference held in the Resources folder to every single asset in the project, and for large projects, this causes serious issues


    EDIT: Seems there's a solution to my issues! See Vadim's reply below, thanks Vadim <3
     
    Last edited: May 27, 2017
    AGregori likes this.
  8. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Yep, this is clearly a dealbreaker. Vadim, please confirm if there is a workaround to go without the resource map.
     
  9. JacobK

    JacobK

    Joined:
    Jun 18, 2013
    Posts:
    20
    It looks like should be possible to use it without the ResourceMap, but I can't get it to work. If you delete the origianl ResourceMap, everything breaks. If you don't add things to the resource map - things don't seem to instantiate properly? Prefabs instantiated via the RTEditor are losing references to their meshes and stuff, can't work out why!
     
    Last edited: May 22, 2017
  10. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi Jacob. Thank you for using Runtime Editor :)

    First of all I have a pretty simple solution for problem
    1) Please import attached package
    2) Open Battlehub\RTSaveLoad\Scripts\Implementation\ResourceMapGen.cs
    3) Add path to folders with objects you are planning to expose to editor. Only objects from these folders (and subfolders) will be added to ResourceMap.
    Code (CSharp):
    1. public static readonly string[] AllowedPath = new string[]
    2. {
    3.     //"Assets/"
    4.     "Assets/EditableObjects/"
    5. }
    4) If you don't want certain objects in scene to be affected by SaveLoad just add PersistentIgnore script to them
    5) Delete old ResourceMap and Build new one using menu
    upload_2017-5-23_12-42-6.png
    6) Problem should be solved

    Also let me explain why I implemented ResourceMap. Consider following script:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Test : MonoBehaviour
    4. {
    5.     public Material MaterialReference;
    6.     void Start ()
    7.     {
    8.         Debug.Log(MaterialReference.GetInstanceID());
    9.     }
    10.  
    11. }
    1) Create Empty GameObject add attach Test script to it
    2) Create new material and drag it to MaterialReference field
    upload_2017-5-23_12-56-28.png
    3) Enter play mode and check instance id written to console.
    4) Duplicate some prefab or material(I copied MyCube when testing it)
    5) Close and re-open unity editor
    6) Enter play mode again
    7) You should see that instance id written to console is different

    At this point I realized that I need to store unique persistent identifiers which are not affected by any changes in project and will remain the same forever. This is why I implemented resource map. But there might be a better way of doing this.

    Btw I think that it is possible to create ResourceMap manually just by creating prefab with ResourceGroups referencing required objects. But it is not very convenient....

    If you want to get rid of SaveLoad subsystem and use your own implementation please do following:
    1) Remove everything from RTSaveLoad folder except Interface subfolder
    upload_2017-5-23_13-10-2.png
    2) Comment //#define RT_USE_DEFAULT_IMPLEMENTATION in IProjectManager.cs and PersistentIgnore.cs
    3) Update Dependencies.cs like this:
    Code (CSharp):
    1. using UnityEngine;
    2. namespace Battlehub.RTSaveLoad
    3. {
    4.     public static class Dependencies
    5.     {
    6.         public static ISerializer Serializer
    7.         {
    8.             get { return null; }
    9.         }
    10.         public static IStorage Storage
    11.         {
    12.             get { return new FileSystemStorage(Application.persistentDataPath); }
    13.         }
    14.         public static IProject Project
    15.         {
    16.             get { return new Project(); }
    17.         }
    18.         public static IAssetBundleLoader BundleLoader
    19.         {
    20.             get { return new AssetBundleLoader(); }
    21.         }
    22.         public static IProjectManager ProjectManager
    23.         {
    24.             get { return null; }[
    25.         }
    26.         public static ISceneManager SceneManager
    27.         {
    28.            get { return null; }
    29.         }
    30.         public static IRuntimeShaderUtil ShaderUtil
    31.         {
    32.             get { return null; }
    33.         }
    34.     }
    35. }
    5) Save&Load will be disabled and Project window will become invisible but RuntimeEditor should continue to work
    6) Now you could provide your own implementation of IProjectManager, ISceneManager, IRuntimeShaderUtil and ISerializer interfaces.

    Also you could avoid using ResourceMap by using DynamicResources instead.
    See http://battlehub.net/RuntimeEditorBasics/RuntimeEditorBasics.pdf section: 8.15 HowTo: Add Dynamic Resource.
    But DynamicResources is little bit limited because only certain types of objects supported. For example Materials and GameObjects supported but ProceduralMaterial is not supported because it does not have public constructor.

    I hope it will help :)

    Regards,
    Vadim
     

    Attached Files:

    Last edited: May 23, 2017
  11. Phil-B7

    Phil-B7

    Joined:
    May 25, 2017
    Posts:
    1
    I get this error in the console when I click the save button in the Runtime Editor:

    InvalidOperationException: Dynamic type is not a contract-type: MouseLook
     
  12. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Locate MouseLook type and find it’s usages (find fields in your scripts which have MouseLook type)

    If MouseLook is not derived from MonoBehavior you could mark MouseLook as
    [ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
    public struct MouseLook {

    If it is derived form MonoBehavior please look through fields of MouseLook and locate custom types and do the same
    [ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
    public class CustomType
    {
    }

    Or ignore fields causing this error either by making them private or by marking them with SerializeIgnore attribute
    public class TestScript : MonoBehaviour {
    [Battlehub.SerializeIgnore]
    public int Test;

    Then click Tools->RTSaveLoad->Build Type Model

    See http://battlehub.net/RuntimeEditorBasics/RuntimeEditorBasics.pdf page 59 add custom type

    Jugged arrays looks like this int[][]. Serializer can’t serialize jugged arrays
    To fix it please import attached package. It will ignore these field.
    To ignore field manually you could do following:

    [Battlehub.SerializeIgnore]
    private someType[][] Array;

    If you need to serialize jugged array you could do following:

    [ProtoContract(AsReferenceDefault = true, ImplicitFields = ImplicitFields.AllFields)]
    public class MyArray
    {
    public int[] Array;
    }

    public MyArray[] m_array;
     

    Attached Files:

  13. JacobK

    JacobK

    Joined:
    Jun 18, 2013
    Posts:
    20
    Vadim - Thanks a bunch! Looks like a good solution, I'll give it a go!

    An ideal solution would be a way to generate a ResourceMap for set objects and their dependencies easily, not sure how much work that would be to implement! (I probably also shouldn't have entire sfx / texture libraries in my project that i'm only using a small amount of!)

    But this all sounds very reasonably designed actually, thanks! Keep up the good work!
     
    Vadim-Andriyanov likes this.
  14. WalterEspinar

    WalterEspinar

    Joined:
    Aug 23, 2011
    Posts:
    84
    Hi Vadim, i want move my objects without your handle, i want move the objects with a simple drag script and arrows key, it is posible to record undo&redo?,
    I have tried moving an object via transform but undo&redo not work
    thanks
     
  15. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi,
    try to do following:
    Code (CSharp):
    1. using UnityEngine;
    2. using Battlehub.RTCommon;
    3.  
    4. public class MoveObject : MonoBehaviour
    5. {
    6.     public Transform Target;
    7.     public KeyCode Key = KeyCode.UpArrow;
    8.     void Update ()
    9.     {
    10.         if(Input.GetKeyDown(Key))
    11.         {
    12.             RuntimeUndo.RecordTransform(Target);
    13.         }
    14.         if(Input.GetKey(Key))
    15.         {
    16.             Target.position += Vector3.up * Time.deltaTime;
    17.         }
    18.         if (Input.GetKeyUp(Key))
    19.         {
    20.             RuntimeUndo.RecordTransform(Target);
    21.         }
    22.     }
    23. }
    24.  
     
    WalterEspinar likes this.
  16. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi Vadim
    sorry for such newbie question: How can I adjust the color of the grid and the grid size?

    Thank you for such a great asset.
    Have you considered other use cases than a level editor e.g. kitchen /furniture planer?
    Joerg
     
  17. WalterEspinar

    WalterEspinar

    Joined:
    Aug 23, 2011
    Posts:
    84
    Wonderfull
    Thanks!
     
    Vadim-Andriyanov likes this.
  18. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi Joerg
    Right now color of gird is hardcoded,
    but you could change it in DrawGrid method in RTHandles/Scripts/RuntimeHandles.cs

    Code (CSharp):
    1. private static void DrawGrid(Vector3 cameraPosition, Vector3 gridOffset, float spacing, float alpha ,float fadeDisance)
    2. {
    3. ....
    4.             GridMaterial.SetFloat("_FadeDistance", fadeDisance);
    5.             GridMaterial.SetPass(0);
    6.  
    7.             GL.Begin(GL.LINES);
    8.             Color color = Color.white;
    9.             color.a = 0.1f * alpha;
    10.             GL.Color(color);
    11. ....
    12.  

    Grid size depends on camera distance.
    To make lines looks bolder you could replace color.a = 0.1f * alpha with color.a = alpha

    upload_2017-5-31_10-26-50.png

    I think that some users already use it as furniture planner

    Regards,
    Vadim
     
    Last edited: May 31, 2017
    j_ho_74 and WalterEspinar like this.
  19. WalterEspinar

    WalterEspinar

    Joined:
    Aug 23, 2011
    Posts:
    84
    Hi Vadin, it is possible to set different clamps rotation per objects?, i have some object that rotate only 180º and others every 90º

    can use Gizmos with different cameras? i want change from camera one to camera two.
     
    Last edited: Jun 2, 2017
  20. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi,
    if I correctly understand question, here is how you can specify rotation clamps per object. Attach ClampAngles script to required objects and set Angle to desired angle

    Code (CSharp):
    1. using Battlehub.RTCommon;
    2. using Battlehub.RTEditor;
    3. using Battlehub.RTHandles;
    4. using System.Collections.Generic;
    5. using System.Linq;
    6. using UnityEngine;
    7.  
    8. public class ClampAngles : MonoBehaviour {
    9.  
    10.     public float Angle = 45;
    11.     private const float DefaultAngle = 15;
    12.     static ClampAngles()
    13.     {
    14.         RuntimeSelection.SelectionChanged += OnRuntimeSelectionChanged;
    15.         RuntimeTools.ToolChanged += OnToolChanged;
    16.     }
    17.  
    18.     private static void OnToolChanged()
    19.     {
    20.         TryUpdateRotationHandle();
    21.     }
    22.  
    23.     private static void OnRuntimeSelectionChanged(Object[] unselectedObjects)
    24.     {
    25.         TryUpdateRotationHandle();
    26.     }
    27.  
    28.     private static void TryUpdateRotationHandle()
    29.     {
    30.         if (RuntimeTools.Current != RuntimeTool.Rotate)
    31.         {
    32.             return;
    33.         }
    34.  
    35.         RotationHandle rotationHandle = RuntimeEditor.Instance.SceneView.HandlesParent.GetComponentInChildren<RotationHandle>(true);
    36.         IEnumerable<ClampAngles> clampAngles = RuntimeSelection.gameObjects.Select(go => go.GetComponent<ClampAngles>());
    37.         if (clampAngles.Any())
    38.         {
    39.             rotationHandle.GridSize = clampAngles.Max(ca => ca.Angle);
    40.         }
    41.         else
    42.         {
    43.             rotationHandle.GridSize = DefaultAngle;
    44.         }
    45.     }
    46. }
    47.  
    Which gizmos you are talking about?
    To Draw gizmos with different cameras attach GLCamera script to required cameras
     
    Evasion4D likes this.
  21. WalterEspinar

    WalterEspinar

    Joined:
    Aug 23, 2011
    Posts:
    84
    I dont have RTEditor, maybe because i have the lite version?

    Assets/Battlehub/RTCommon/Scripts/ClampAngles.cs(3,17): error CS0234: The type or namespace name `RTEditor' does not exist in the namespace `Battlehub'. Are you missing an assembly reference?


    And with the camera when i try to change from camera1 to camera2 the gizmos are with problems
     

    Attached Files:

    Last edited: Jun 6, 2017
  22. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    https://forum.unity3d.com/threads/runtime-handles.428094/#post-3096726
     
  23. FLYUPAV

    FLYUPAV

    Joined:
    Aug 1, 2013
    Posts:
    34
    I am wondering how to reduce the decimal number of transform components such as Position, Rotation and scale? I want to have them just showing integers without decimals point
    Thanks
     
  24. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi, please import attached package
    I have added following field to
    Vector3 editor

    public bool RoundToInt;

    and modified TransformEditor like this

    Code (CSharp):
    1. public class TransformEditor : ComponentEditor
    2.     {
    3.         protected override void InitEditor(PropertyEditor editor, PropertyDescriptor descriptor)
    4.         {
    5.             base.InitEditor(editor, descriptor);
    6.             if(RuntimeTools.LockAxes == null)
    7.             {
    8.                 return;
    9.             }
    10.             if(descriptor.ComponentMemberInfo == Strong.MemberInfo((Transform x) => x.position))
    11.             {
    12.                 Vector3Editor vector3Editor = (Vector3Editor)editor;
    13.                 vector3Editor.RoundToInt = true;
    Regards,
    Vadim
     

    Attached Files:

    Evasion4D likes this.
  25. FLYUPAV

    FLYUPAV

    Joined:
    Aug 1, 2013
    Posts:
    34
    Thanks but, I got 2 errors:
    1) Assets/Battlehub/RTEditor/Scripts/Editors/TransformEditor.cs(1,17): error CS0234: The type or namespace name `RTCommon' does not exist in the namespace `Battlehub'. Are you missing an assembly reference?
    2) Assets/Battlehub/RTEditor/Scripts/Editors/PropertyEditors/Vector3Editor.cs(7,34): error CS0246: The type or namespace name `PropertyEditor`1' could not be found. Are you missing a using directive or an assembly reference?


     
  26. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Are you using latest version of RTEditor from asset store?
    Have you imported attached package over RTEditor package?
    (Import RuntimeEditor package from asset store, then import TransformIntEditor package from previous post. Does problem still exists after this?)
     
  27. FLYUPAV

    FLYUPAV

    Joined:
    Aug 1, 2013
    Posts:
    34
    Unfortunately I updated to the latest version but the style of the old UI is more convenient with my current project. Actually the old version is more user friendly for me. Could you please give me the code compatible with the old version?
    Thanks and appreciated
     
  28. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    There are several previous versions 1.0, 1.1, 1.2. Which is yours? It should be on first page of Battlehub/RTEditor/RuntimeEditorBasics.pdf included in your package.
     
  29. FLYUPAV

    FLYUPAV

    Joined:
    Aug 1, 2013
    Posts:
    34
    Ver.1.1 03.10.2016
    Thanks and appreciated
     
  30. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Replace RTEditor/Scripts/TransformComponent.cs with this code

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Linq;
    4. using System.Collections.Generic;
    5. using Battlehub.RTHandles;
    6.  
    7. namespace Battlehub.RTEditor
    8. {
    9.     public class TransformComponent : MonoBehaviour
    10.     {
    11.         public bool RoundToInt = true;
    12.  
    13.         public Toggle EnableDisableToggle;
    14.         public GameObject TransformComponentUI;
    15.         public InputField PositionX;
    16.         public InputField PositionY;
    17.         public InputField PositionZ;
    18.         public InputField RotationX;
    19.         public InputField RotationY;
    20.         public InputField RotationZ;
    21.         public InputField ScaleX;
    22.         public InputField ScaleY;
    23.         public InputField ScaleZ;
    24.         public Button Reset;
    25.  
    26.         private Transform[] m_transforms;
    27.         private HashSet<GameObject> m_selectedGameObjects = new HashSet<GameObject>();
    28.  
    29.         private bool m_isPositionEditing;
    30.         private bool m_isRotationEditing;
    31.         private bool m_isScaleEditing;
    32.  
    33.         private DragField[] m_dragFields;
    34.  
    35.         private void Awake()
    36.         {
    37.             RuntimeSelection.SelectionChanged += OnRuntimeSelectionChanged;
    38.             RuntimeUndo.BeforeUndo += OnBeforeUndo;
    39.         }
    40.  
    41.         private void OnDestroy()
    42.         {
    43.             RuntimeSelection.SelectionChanged -= OnRuntimeSelectionChanged;
    44.             RuntimeUndo.BeforeUndo -= OnBeforeUndo;
    45.         }
    46.  
    47.         private void OnEnable()
    48.         {
    49.             ExposeToEditor.TransformChanged += OnTransformChanged;
    50.  
    51.             PositionX.onValueChanged.AddListener(OnPositionXChanged);
    52.             PositionY.onValueChanged.AddListener(OnPositionYChanged);
    53.             PositionZ.onValueChanged.AddListener(OnPositionZChanged);
    54.             RotationX.onValueChanged.AddListener(OnRotationXChanged);
    55.             RotationY.onValueChanged.AddListener(OnRotationYChanged);
    56.             RotationZ.onValueChanged.AddListener(OnRotationZChanged);
    57.             ScaleX.onValueChanged.AddListener(OnScaleXChanged);
    58.             ScaleY.onValueChanged.AddListener(OnScaleYChanged);
    59.             ScaleZ.onValueChanged.AddListener(OnScaleZChanged);
    60.  
    61.             PositionX.onEndEdit.AddListener(OnEndEdit);
    62.             PositionY.onEndEdit.AddListener(OnEndEdit);
    63.             PositionZ.onEndEdit.AddListener(OnEndEdit);
    64.             RotationX.onEndEdit.AddListener(OnEndEdit);
    65.             RotationY.onEndEdit.AddListener(OnEndEdit);
    66.             RotationZ.onEndEdit.AddListener(OnEndEdit);
    67.             ScaleX.onEndEdit.AddListener(OnEndEdit);
    68.             ScaleY.onEndEdit.AddListener(OnEndEdit);
    69.             ScaleZ.onEndEdit.AddListener(OnEndEdit);
    70.  
    71.             Reset.onClick.AddListener(OnResetClick);
    72.             EnableDisableToggle.onValueChanged.AddListener(OnEnableDisableValueChanged);
    73.  
    74.             m_dragFields = GetComponentsInChildren<DragField>();
    75.             for(int i = 0; i < m_dragFields.Length; ++i)
    76.             {
    77.                 m_dragFields[i].EndDrag.AddListener(OnDragFieldEndDrag);
    78.                 if(RoundToInt)
    79.                 {
    80.                     m_dragFields[i].IncrementFactor = 1.0f;
    81.                 }
    82.             }
    83.  
    84.             OnRuntimeSelectionChanged(null);
    85.         }
    86.  
    87.         private void OnApplicationQuit()
    88.         {
    89.             Unsubscribe();
    90.         }
    91.  
    92.         private void OnDisable()
    93.         {
    94.             Unsubscribe();
    95.         }
    96.  
    97.         private void Unsubscribe()
    98.         {
    99.             ExposeToEditor.TransformChanged -= OnTransformChanged;
    100.  
    101.             PositionX.onValueChanged.RemoveListener(OnPositionXChanged);
    102.             PositionY.onValueChanged.RemoveListener(OnPositionYChanged);
    103.             PositionZ.onValueChanged.RemoveListener(OnPositionZChanged);
    104.             RotationX.onValueChanged.RemoveListener(OnRotationXChanged);
    105.             RotationY.onValueChanged.RemoveListener(OnRotationYChanged);
    106.             RotationZ.onValueChanged.RemoveListener(OnRotationZChanged);
    107.             ScaleX.onValueChanged.RemoveListener(OnScaleXChanged);
    108.             ScaleY.onValueChanged.RemoveListener(OnScaleYChanged);
    109.             ScaleZ.onValueChanged.RemoveListener(OnScaleZChanged);
    110.  
    111.             PositionX.onEndEdit.RemoveListener(OnEndEdit);
    112.             PositionY.onEndEdit.RemoveListener(OnEndEdit);
    113.             PositionZ.onEndEdit.RemoveListener(OnEndEdit);
    114.             RotationX.onEndEdit.RemoveListener(OnEndEdit);
    115.             RotationY.onEndEdit.RemoveListener(OnEndEdit);
    116.             RotationZ.onEndEdit.RemoveListener(OnEndEdit);
    117.             ScaleX.onEndEdit.RemoveListener(OnEndEdit);
    118.             ScaleY.onEndEdit.RemoveListener(OnEndEdit);
    119.             ScaleZ.onEndEdit.RemoveListener(OnEndEdit);
    120.  
    121.             Reset.onClick.RemoveListener(OnResetClick);
    122.  
    123.             EnableDisableToggle.onValueChanged.RemoveListener(OnEnableDisableValueChanged);
    124.  
    125.             if (m_dragFields != null)
    126.             {
    127.                 for (int i = 0; i < m_dragFields.Length; ++i)
    128.                 {
    129.                     if (m_dragFields[i])
    130.                     {
    131.                         m_dragFields[i].EndDrag.RemoveListener(OnDragFieldEndDrag);
    132.                     }
    133.                 }
    134.             }
    135.         }
    136.  
    137.         private bool m_handleTransformChange = true;
    138.         private void HandlePositionChanged()
    139.         {
    140.             if(!m_handleTransformChange)
    141.             {
    142.                 return;
    143.             }
    144.  
    145.  
    146.             if (m_transforms == null || m_transforms.Length == 0)
    147.             {
    148.                 return;
    149.             }
    150.             float xVal;
    151.             if (!float.TryParse(PositionX.text, out xVal))
    152.             {
    153.                 return;
    154.             }
    155.             float yVal;
    156.             if (!float.TryParse(PositionY.text, out yVal))
    157.             {
    158.                 return;
    159.             }
    160.             float zVal;
    161.             if (!float.TryParse(PositionZ.text, out zVal))
    162.             {
    163.                 return;
    164.             }
    165.  
    166.             if (!m_isPositionEditing)
    167.             {
    168.                 m_isPositionEditing = true;
    169.                 RecordTransforms();
    170.             }
    171.  
    172.             if (RoundToInt)
    173.             {
    174.                 xVal = Mathf.RoundToInt(xVal);
    175.                 yVal = Mathf.RoundToInt(yVal);
    176.                 zVal = Mathf.RoundToInt(zVal);
    177.             }
    178.             for (int i = 0; i < m_transforms.Length; ++i)
    179.             {
    180.                 m_transforms[i].position = new Vector3(xVal, yVal, zVal);
    181.             }
    182.         }
    183.  
    184.         private void HandleRotationChanged()
    185.         {
    186.             if (!m_handleTransformChange)
    187.             {
    188.                 return;
    189.             }
    190.             if (m_transforms == null || m_transforms.Length == 0)
    191.             {
    192.                 return;
    193.             }
    194.             float xVal;
    195.             if (!float.TryParse(RotationX.text, out xVal))
    196.             {
    197.                 return;
    198.             }
    199.             float yVal;
    200.             if (!float.TryParse(RotationY.text, out yVal))
    201.             {
    202.                 return;
    203.             }
    204.             float zVal;
    205.             if (!float.TryParse(RotationZ.text, out zVal))
    206.             {
    207.                 return;
    208.             }
    209.  
    210.             if (!m_isRotationEditing)
    211.             {
    212.                 m_isRotationEditing = true;
    213.                 RecordTransforms();
    214.             }
    215.  
    216.             if (RoundToInt)
    217.             {
    218.                 xVal = Mathf.RoundToInt(xVal);
    219.                 yVal = Mathf.RoundToInt(yVal);
    220.                 zVal = Mathf.RoundToInt(zVal);
    221.             }
    222.  
    223.             for (int i = 0; i < m_transforms.Length; ++i)
    224.             {
    225.                 m_transforms[i].rotation = Quaternion.Euler(xVal, yVal, zVal);
    226.             }
    227.         }
    228.  
    229.         private void HandleScaleChanged()
    230.         {
    231.             if (!m_handleTransformChange)
    232.             {
    233.                 return;
    234.             }
    235.             if (m_transforms == null || m_transforms.Length == 0)
    236.             {
    237.                 return;
    238.             }
    239.             float xVal;
    240.             if (!float.TryParse(ScaleX.text, out xVal))
    241.             {
    242.                 return;
    243.             }
    244.             float yVal;
    245.             if (!float.TryParse(ScaleY.text, out yVal))
    246.             {
    247.                 return;
    248.             }
    249.             float zVal;
    250.             if (!float.TryParse(ScaleZ.text, out zVal))
    251.             {
    252.                 return;
    253.             }
    254.  
    255.             if (!m_isScaleEditing)
    256.             {
    257.                 m_isScaleEditing = true;
    258.                 RecordTransforms();
    259.             }
    260.  
    261.             if (RoundToInt)
    262.             {
    263.                 xVal = Mathf.RoundToInt(xVal);
    264.                 yVal = Mathf.RoundToInt(yVal);
    265.                 zVal = Mathf.RoundToInt(zVal);
    266.             }
    267.  
    268.             for (int i = 0; i < m_transforms.Length; ++i)
    269.             {
    270.                 m_transforms[i].localScale = new Vector3(xVal, yVal, zVal);
    271.             }
    272.         }
    273.  
    274.         private void EndEditField(InputField field)
    275.         {
    276.             float val;
    277.             if (!float.TryParse(field.text, out val))
    278.             {
    279.                 field.text = "0";
    280.             }
    281.             else
    282.             {
    283.                 if(RoundToInt)
    284.                 {
    285.                     field.text = Mathf.RoundToInt(val).ToString();
    286.                 }
    287.              
    288.             }
    289.          
    290.         }
    291.  
    292.         private void OnEndEdit(string value)
    293.         {
    294.             EndEditField(PositionX);
    295.             EndEditField(PositionY);
    296.             EndEditField(PositionZ);
    297.             EndEditField(RotationX);
    298.             EndEditField(RotationY);
    299.             EndEditField(RotationZ);
    300.             EndEditField(ScaleX);
    301.             EndEditField(ScaleY);
    302.             EndEditField(ScaleZ);
    303.  
    304.             if(m_isPositionEditing || m_isRotationEditing || m_isScaleEditing)
    305.             {
    306.                 RecordTransforms();
    307.  
    308.                 m_isPositionEditing = false;
    309.                 m_isRotationEditing = false;
    310.                 m_isScaleEditing = false;
    311.             }
    312.         }
    313.  
    314.         private void OnDragFieldEndDrag()
    315.         {
    316.             if (m_isPositionEditing || m_isRotationEditing || m_isScaleEditing)
    317.             {
    318.                 RecordTransforms();
    319.  
    320.                 m_isPositionEditing = false;
    321.                 m_isRotationEditing = false;
    322.                 m_isScaleEditing = false;
    323.             }
    324.         }
    325.  
    326.         private void OnBeforeUndo()
    327.         {
    328.             if (m_isPositionEditing || m_isRotationEditing || m_isScaleEditing)
    329.             {
    330.                 RecordTransforms();
    331.  
    332.                 m_isPositionEditing = false;
    333.                 m_isRotationEditing = false;
    334.                 m_isScaleEditing = false;
    335.             }
    336.         }
    337.  
    338.         private void RecordTransforms()
    339.         {
    340.             RuntimeUndo.BeginRecord();
    341.             for (int i = 0; i < m_transforms.Length; ++i)
    342.             {
    343.                 if(m_transforms[i] != null)
    344.                 {
    345.                     RuntimeUndo.RecordObject(m_transforms[i]);
    346.                 }
    347.             }
    348.             RuntimeUndo.EndRecord();
    349.         }
    350.  
    351.  
    352.         private void OnPositionXChanged(string value)
    353.         {
    354.             HandlePositionChanged();
    355.         }
    356.  
    357.         private void OnPositionYChanged(string value)
    358.         {
    359.             HandlePositionChanged();
    360.         }
    361.  
    362.         private void OnPositionZChanged(string value)
    363.         {
    364.             HandlePositionChanged();
    365.         }
    366.  
    367.         private void OnRotationXChanged(string value)
    368.         {
    369.             HandleRotationChanged();
    370.         }
    371.  
    372.         private void OnRotationYChanged(string value)
    373.         {
    374.             HandleRotationChanged();
    375.         }
    376.  
    377.         private void OnRotationZChanged(string value)
    378.         {
    379.             HandleRotationChanged();
    380.         }
    381.  
    382.         private void OnScaleXChanged(string value)
    383.         {
    384.             HandleScaleChanged();
    385.         }
    386.  
    387.         private void OnScaleYChanged(string value)
    388.         {
    389.             HandleScaleChanged();
    390.         }
    391.  
    392.         private void OnScaleZChanged(string value)
    393.         {
    394.             HandleScaleChanged();
    395.         }
    396.  
    397.         private void OnTransformChanged(ExposeToEditor obj)
    398.         {
    399.          
    400.             if (!m_selectedGameObjects.Contains(obj.gameObject))
    401.             {
    402.                 return;
    403.             }
    404.  
    405.             m_handleTransformChange = false;
    406.             UpdateAllFields();
    407.             m_handleTransformChange = true;
    408.         }
    409.  
    410.         private void OnRuntimeSelectionChanged(Object[] unselected)
    411.         {
    412.          
    413.             GameObject[] gameObjects = RuntimeSelection.gameObjects;
    414.             if(gameObjects == null)
    415.             {
    416.                 m_selectedGameObjects.Clear();
    417.  
    418.                 EnableDisableToggle.gameObject.SetActive(false);
    419.                 TransformComponentUI.gameObject.SetActive(false);
    420.                 m_transforms = null;
    421.             }
    422.             else
    423.             {
    424.                 m_selectedGameObjects.Clear();
    425.                 m_transforms = gameObjects.Where(g => g != null && g.GetComponent<ExposeToEditor>()).Select(g => g.GetComponent<Transform>()).Where(t => t.GetType() == typeof(Transform)).ToArray();
    426.                 for(int i = 0; i < m_transforms.Length; ++i)
    427.                 {
    428.                     m_selectedGameObjects.Add(m_transforms[i].gameObject);
    429.                 }
    430.  
    431.                 if (m_transforms.Length > 0)
    432.                 {
    433.                     EnableDisableToggle.gameObject.SetActive(true);
    434.                     TransformComponentUI.gameObject.SetActive(true);
    435.                     m_handleTransformChange = false;
    436.                     UpdateAllFields();
    437.                     m_handleTransformChange = true;
    438.                 }
    439.                 else
    440.                 {
    441.                     EnableDisableToggle.gameObject.SetActive(false);
    442.                     TransformComponentUI.gameObject.SetActive(false);
    443.                 }
    444.             }
    445.         }
    446.  
    447.         private void UpdateAllFields()
    448.         {
    449.             var positionX = m_transforms.Where(t => t != null).Select(t => t.position.x);
    450.             var positionY = m_transforms.Where(t => t != null).Select(t => t.position.y);
    451.             var positionZ = m_transforms.Where(t => t != null).Select(t => t.position.z);
    452.             var rotationX = m_transforms.Where(t => t != null).Select(t => t.rotation.eulerAngles.x);
    453.             var rotationY = m_transforms.Where(t => t != null).Select(t => t.rotation.eulerAngles.y);
    454.             var rotationZ = m_transforms.Where(t => t != null).Select(t => t.rotation.eulerAngles.z);
    455.             var scaleX = m_transforms.Where(t => t != null).Select(t => t.localScale.x);
    456.             var scaleY = m_transforms.Where(t => t != null).Select(t => t.localScale.y);
    457.             var scaleZ = m_transforms.Where(t => t != null).Select(t => t.localScale.z);
    458.             SetFieldValue(PositionX, positionX);
    459.             SetFieldValue(PositionY, positionY);
    460.             SetFieldValue(PositionZ, positionZ);
    461.             SetFieldValue(RotationX, rotationX);
    462.             SetFieldValue(RotationY, rotationY);
    463.             SetFieldValue(RotationZ, rotationZ);
    464.             SetFieldValue(ScaleX, scaleX);
    465.             SetFieldValue(ScaleY, scaleY);
    466.             SetFieldValue(ScaleZ, scaleZ);
    467.             EnableDisableToggle.isOn = m_transforms.Where(t => t != null).All(t => t.gameObject.activeSelf);
    468.         }
    469.  
    470.         private void SetFieldValue(InputField field, IEnumerable<float> values)
    471.         {
    472.             if (values.Any(p => p != values.First()))
    473.             {
    474.                 field.text = string.Empty;
    475.             }
    476.             else
    477.             {
    478.                 if(RoundToInt)
    479.                 {
    480.                     field.text = Mathf.RoundToInt(values.First()).ToString();
    481.                 }
    482.                 else
    483.                 {
    484.                     field.text = values.First().ToString();
    485.                 }
    486.              
    487.             }
    488.         }
    489.  
    490.         private void OnResetClick()
    491.         {
    492.             float zero = 0;
    493.             float one = 1;
    494.             PositionX.text = zero.ToString();
    495.             PositionY.text = zero.ToString();
    496.             PositionZ.text = zero.ToString();
    497.             RotationX.text = zero.ToString();
    498.             RotationY.text = zero.ToString();
    499.             RotationZ.text = zero.ToString();
    500.             ScaleX.text = one.ToString();
    501.             ScaleY.text = one.ToString();
    502.             ScaleZ.text = one.ToString();
    503.         }
    504.  
    505.         private void OnEnableDisableValueChanged(bool value)
    506.         {
    507.             if (!m_handleTransformChange)
    508.             {
    509.                 return;
    510.             }
    511.             for (int i = 0; i < m_transforms.Length; ++i)
    512.             {
    513.                 m_transforms[i].gameObject.SetActive(value);
    514.             }
    515.         }
    516.     }
    517. }
    518.  
     

    Attached Files:

  31. FLYUPAV

    FLYUPAV

    Joined:
    Aug 1, 2013
    Posts:
    34
    ;) Fantastic Job dude. Thanks
     
  32. death_au

    death_au

    Joined:
    Apr 18, 2017
    Posts:
    3
    Is there any way to import an Asset Bundle at runtime and have the resources within exposed to the editor? Even if I have to do something specific to package a resource map along with the asset bundle.
     
  33. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    To create asset bundle with resource map do following:
    1) assign asset bundle to object and all of it's dependencies
    2) click Tools->RTSaveLoad->Build Resource Map or (Build All) menu item
    upload_2017-6-21_14-36-57.png

    Asset Bundle will be moved to StreamingAssets folder
    upload_2017-6-21_14-38-0.png

    See AddResourcesTest script for details on how to import assets from asset bundle at runtime
    (To add all assets form bundle use Keypad 6 key)
    upload_2017-6-21_14-39-47.png

    Here is code:
    Code (CSharp):
    1.   if (InputController.GetKeyDown(AddAssetBundleKey2))
    2.             {
    3.                 ProjectItem rootFolder = m_projectManager.Project;
    4.                 m_projectManager.AddBundledResources(rootFolder, "bundledemo",
    5.                     (obj, assetName) =>
    6.                     {
    7.                         return true;
    8.                     },
    9.                     addedItems =>
    10.                     {
    11.                         for (int i = 0; i < addedItems.Length; ++i)
    12.                         {
    13.                             Debug.Log(addedItems[i].ToString() + " added");
    14.                         }
    15.                     });
    16.             }
    17.  
    Regards,
    Vadim
     
    BackwoodsGaming likes this.
  34. death_au

    death_au

    Joined:
    Apr 18, 2017
    Posts:
    3
    Thanks Vadim, that's exactly what I needed!
    I'm having a small issue, though. I've added a prefab to an asset bundle and loaded it as you describe which puts the object in the project window correctly, and I can drag it into the editor, but the object is then not selectable in the editor. I can click on it in the Heirarchy window, but I can't select it in the editor, and I can't drop materials on it.
    I assume I'm missing something really basic, but I can't figure out what it is.
     
  35. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Difficult to say. Could you add collider of appropriate size to your object?
     
  36. death_au

    death_au

    Joined:
    Apr 18, 2017
    Posts:
    3
    I've added mesh colliders to the meshes and now I can drag materials on to the meshes, but I still can't select them. This is good enough for my purposes for now, as I can still select them in the hierarchy window.
    Through playing around with things, I think it might be related to the fact that the mesh I'm using has submeshes (it split itself automatically on import due to having too many vertices). The submeshes are not visible in the heirarchy and I'm not sure why that is.
     
  37. FeynmanRen100

    FeynmanRen100

    Joined:
    Sep 6, 2013
    Posts:
    22

    Hi Vadim,
    Are there any ways to load the scene from the runtime editor? since the player won't just use the runtime editor build.

    thanks
     
  38. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Not sure if I understand question correctly. Could you clarify a little bit which scene runtime editor should load? Unity scene? or what?
     
  39. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Send your mesh to Vadim.Andriyanov@outlook.com and I could test it.
     
  40. FeynmanRen100

    FeynmanRen100

    Joined:
    Sep 6, 2013
    Posts:
    22
    1. the scene is created by players, for example, if player create a new scene and put some objects into it, then save the scene to a *.rtsc file, next time when the play opens the editor is there a way to load the scene, or upload the scene to a server and players can load the scene ?

    2.When I use this editor, I found this bug few times when close and open scene continuously [editor version is the lastest], see the attachment.

    3.If I wanna implement this kind of feature, Is it possible with this editor, the editor provides some default prefabs to the player in the 1st version, later we can publish more asset bundles, so the player can download these bundles to make more scene since the editor need to build the resource map. I do not quite understand why you have this kind of resource mapping system.

    What I think the way will be like this,
    we put some prefabs or asset bundles in a specific folder when the editor read that info, the player can use those bundles to make their scenes when saving the scene, we just need to save the asset bundle type and the serialized instance value. please let me know what do you think about this?

    BTW, this editor is so good, you did a fantasic job, save me lots of time.
     

    Attached Files:

  41. Evasion4D

    Evasion4D

    Joined:
    Aug 8, 2013
    Posts:
    16
    This problem, as well as others, have appeared with Unity version 5.6, or at least with the latest
    (It did not exist before)
    By changing the size of the screen, or by moving one of the PanelResizer, it restores the display correctly

    Vadim,
    I hope you will be able to remedy this as well as the bug of the Asset Bundles that I sent you by email

    Jean Michel
     
    Last edited: Jul 7, 2017
    Vadim-Andriyanov likes this.
  42. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    1. You could use following code to load scenes
    Code (CSharp):
    1. void Update () {
    2.  
    3.         if (Input.GetKeyDown(KeyCode.Space))
    4.         {
    5.             if(Dependencies.ProjectManager.Project == null)
    6.             {
    7.                 Dependencies.ProjectManager.LoadProject("Assets", root =>
    8.                 {
    9.                     SceneLoad();
    10.                 });
    11.             }
    12.             else
    13.             {
    14.                 SceneLoad();
    15.             }
    16.          }
    17.     }
    18.  
    19.     private void SceneLoad()
    20.     {
    21.         Dependencies.Project.Load(new[] { Application.persistentDataPath + "/Assets/testscene.rtsc" }, result =>
    22.         {
    23.             ProjectItem scene = result.Data[0];
    24.  
    25.             Dependencies.SceneManager.LoadScene(scene, () =>
    26.             {
    27.                 Camera.main.rect = new Rect(Vector2.zero, Vector2.one);
    28.                 //done
    29.             });
    30.         });
    31.     }
    2. Not sure I am able to reproduce this. I have unity 5.6.1. I will try to install 5.6.2 and try it there
    3. You could use two runtime editors:
    "first" will be given to end users,
    "second" will not be given to end users but instead will be used to build new asset bundles for "first" runtime editor
    * "second" runtime editor will add required part of resource map to created asset bundles.

    If you interested why I implemented resource map here is post where I tried to describe it:
    https://forum.unity3d.com/threads/runtime-editor.470084/#post-3080411

    Regards,
    Vadim
     
  43. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi Jean Michel

    It looks like I found unity bug. https://issuetracker.unity3d.com/is...ter-assetbundle-dot-loadallassets-method-call

    Here is bug description:

    All static fields are set to null after AssetBundle.LoadAllAssets<TextAsset>() method call

    Unity 5.6.2.f1

    static fields of all scripts are reset to null after AssetBundle.LoadAllAssets<TextAsset>() method call

    Steps to reproduce:
    1) Import LoadTextAssetsIssue.unitypackage
    2) Open Test scene
    3) Enter Play mode
    Actual Result: Debug.Assert(Instance != null); assertion failed
    Expected Result: No errors


    Detailed Steps:
    1) Create Empty GameObject
    2) Create empty script and attach it to GameObject
    3) Create Prefab using GameObject from step 1
    4) Select AssetBundle field of Prefab and set it to 'bundle' (or any other name)
    5) Create asset bundle using following code BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
    6) Create TestScript and attach it to scene object
    Code (CSharp):
    1. public class TestScript : MonoBehaviour
    2. {
    3.     public static TestScript Instance;
    4.  
    5.     private void Awake()
    6.     {
    7.        Instance = this; //Set static field
    8.     }
    9.  
    10.     private void Start()
    11.     {
    12.         AssetBundle bundle = AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/bundle");
    13.         TextAsset[] assets = bundle.LoadAllAssets<TextAsset>();  //LoadAllAssets<TextAsset>
    14.         for (int i = 0; i < assets.Length; ++i)
    15.         {
    16.             Debug.Log(assets.name);
    17.         }
    18.     }
    19.  
    20.    private void Update ()
    21.     {
    22.         Debug.Assert(Instance != null);  //Instance is null here :|
    23.     }
    24. }
    7) Enter play mode:
    Actual Result: Debug.Assert(Instance != null); assertion failed
    Expected Result: No errors



    I didn't found workaround for this so far, so I would ask you to rollback to unity 5.6.1 for some period of time.

    Regards,
    Vadim
     

    Attached Files:

    Last edited: Jul 13, 2017
    Evasion4D likes this.
  44. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Hi Vadim,
    thank for your help so far. Can you please tell me how to correctly instantiate a GameObject via c# script so that it works properly with the Runtime Editor. So far i have instantiated it and attached a "Expose to editor" component to it, but the undo/redo does not recognize the transform changes or if the GameObject is created.
    Thanks for your help.
    Regards ,
    Joerg
     
  45. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi Joerg
    Following code should work

    Code (CSharp):
    1. private void Update () {
    2.         if(Input.GetKeyDown(KeyCode.KeypadEnter))
    3.         {
    4.             GameObject go = GameObject.CreatePrimitive(PrimitiveType.Capsule);
    5.             go.AddComponent<ExposeToEditor>();
    6.         }
    7.     }
    optionally you could do following (this will allow to remove object with undo button)
    Code (CSharp):
    1.     private void Update () {
    2.         if(Input.GetKeyDown(KeyCode.KeypadEnter))
    3.         {
    4.             GameObject go = GameObject.CreatePrimitive(PrimitiveType.Capsule);
    5.             go.AddComponent<ExposeToEditor>();
    6.  
    7.             RegisterCreatedObject(go);
    8.         }
    9.     }
    10.  
    11.     private static void RegisterCreatedObject(GameObject go)
    12.     {
    13.         RuntimeUndo.BeginRecord();
    14.         RuntimeUndo.RecordSelection();
    15.         RuntimeUndo.BeginRegisterCreateObject(go);
    16.         RuntimeUndo.EndRecord();
    17.  
    18.         bool isEnabled = RuntimeUndo.Enabled;
    19.         RuntimeUndo.Enabled = false;
    20.         RuntimeSelection.activeGameObject = go;
    21.         RuntimeUndo.Enabled = isEnabled;
    22.  
    23.         RuntimeUndo.BeginRecord();
    24.         RuntimeUndo.RegisterCreatedObject(go);
    25.         RuntimeUndo.RecordSelection();
    26.         RuntimeUndo.EndRecord();
    27.     }
    Regards,
    Vadim
     
  46. j_ho_74

    j_ho_74

    Joined:
    Aug 13, 2014
    Posts:
    24
    Rocks. Thanks for the super fast answer.
    If I may bother you again?
    Where do you register if a object is transformed? Is it the ExposetoEditor.TransformHasChanged which registers the transform changes?
    Thanks a lot.

    P.S. Do you by chance have a roadmap for the runtime editor?
     
  47. Evasion4D

    Evasion4D

    Joined:
    Aug 8, 2013
    Posts:
    16
    Hi j_ho_74,

    Have you tried with:

    private void Awake()
    {
    ExposeToEditor.TransformChanged += OnTransformChanged;
    }

    private void OnTransformChanged(ExposeToEditor gobj){
    ...
    }

    Jean Michel
     
  48. Holo-Denis

    Holo-Denis

    Joined:
    May 17, 2017
    Posts:
    3
    Hallo Vadim,
    We love your Editor. We are currently trying out whether we can export this Editor to UWP (Windows Store). While trying to Export.
    We get following Errors.
    Editor Errors.PNG

    Can you tell me whether those Errors are fixable or more problematic.

    Regards,
    Denis
     
    Last edited: Jul 20, 2017
  49. PeteGartside

    PeteGartside

    Joined:
    Nov 26, 2016
    Posts:
    5
  50. Vadim-Andriyanov

    Vadim-Andriyanov

    Joined:
    Sep 22, 2015
    Posts:
    125
    Hi Denis, sorry I didn't respond for a long time, today I tried to build UWP with following configuration, and have no errors
    upload_2017-8-1_12-14-57.png

    Have you managed to fix these errors?
    How to reproduce them?

    Regards,
    Vadim