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 1 forks source link

Is it possible to override the Play button? #93

Closed BattlehubCode closed 1 year ago

BattlehubCode commented 1 year ago

Yes it is possible:

  1. Create your view model derived from ToolsViewModel and override "IsPlay" property
using Battlehub.RTEditor.ViewModels;
using UnityEngine;
using UnityWeld.Binding;

namespace MyNamespace
{
    [Binding]
    public class MyToolsViewModel : ToolsViewModel
    {
        [Binding]
        public override bool IsPlay
        {
            get
            {
                return base.IsPlay;
            }
            set
            {
                base.IsPlay = value;
                Debug.Log(value);
            }
        }
    }
}
  1. Create "OverrideToolsPanel" script
    
    using Battlehub.RTEditor;
    using Battlehub.RTEditor.ViewModels;
    using UnityEngine;

namespace MyNamespace { public class OverrideToolsPanel : LayoutExtension { [SerializeField] public RectTransform m_toolsPrefab;

    protected override void OnAfterBuildLayout(IWindowManager wm)
    {
        var tools = Instantiate(m_toolsPrefab);
        tools.gameObject.SetActive(true);

        ViewModelBase.ReplaceWith<MyToolsViewModel>(tools);

        wm.SetTools(tools);
    }
}

}



![image](https://github.com/Battlehub0x/RTE_Docs/assets/15802443/127bd00b-f14e-4194-9582-4623a5042b8e)
nomad5oul commented 1 year ago

@Battlehub0x Is it possible to hide the Play button and if so how can this be done please?

Something like this maybe or another way?

/// Hide existing menu item    
[MenuCommand("MenuHelp/About RTE", hide: true)]
public static void HideAbout() { }
BattlehubCode commented 1 year ago

Yes, create prefab variant of ToolsView

image

Disable "Play" toggle

image

And use ToolsView Variant instead of ToolsView

image