BattlehubCode / RTE_Docs

This is a repository for Runtime Editor documentation, discussion and tracking features and issues.
https://assetstore.unity.com/packages/tools/modeling/runtime-editor-64806
11 stars 0 forks source link

Box Selection for meshes with read/write disabled #60

Closed BattlehubCode closed 2 years ago

BattlehubCode commented 2 years ago

To select any object, which is imported from an assetbundle, the mesh must be marked as read/write enabled (only then mesh colliders can be added at runtime). But I dont want to enable read/write as it is consuming huge memory and crashing my webGl app. Anyone knows how to select object without read/write enabled?

BattlehubCode commented 2 years ago

You can use another 'box selection method '. For example, LooseFitting - which will work at the bounding box level. It is not perfect, but at the same time it does not require the read/write enabled parameter to be set to true.

using Battlehub.RTEditor;
using Battlehub.RTHandles;

public class ChangeBoxSelectionMethod : SceneComponentExtension
{
    protected override void OnSceneActivated(IRuntimeSceneComponent sceneComponent)
    {
        base.OnSceneActivated(sceneComponent);

        sceneComponent.BoxSelection.Method = BoxSelectionMethod.LooseFitting;

    }
}
BattlehubCode commented 2 years ago

You will need to update BoxSelection.cs as following:

image

 public BoxSelectionMethod Method
  {
      get { return m_method; }
      set { m_method = value; }
  }