protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Sprite != null && Sprite.ParentScene == null) //show only when not in a scene { var scene = CreateScene(false); scene.Mode = Component_Scene.ModeEnum._2D; instanceInScene = (Component_Sprite)Sprite.Clone(); scene.AddComponent(instanceInScene); scene.Enabled = true; if (Document != null) { Document.UndoSystem.ListOfActionsChanged += UndoSystem_ListOfActionsChanged; } if (ObjectOfWindow != null) { SelectObjects(new object[] { ObjectOfWindow }); } } }
void CreateObject() { instanceInScene?.Dispose(); instanceInScene = (Component_Sprite)Sprite.Clone(); Scene.AddComponent(instanceInScene); //var type = Sprite.GetProvidedType(); //if( type != null ) //{ // instanceInScene = (Component_Sprite)Scene.CreateComponent( type ); //} }
protected override void Viewport_UpdateBeforeOutput(Viewport viewport) { base.Viewport_UpdateBeforeOutput(viewport); if (Sprite != null && Sprite.ParentScene == null && needRecreateInstance) { instanceInScene?.Dispose(); instanceInScene = (Component_Sprite)Sprite.Clone(); Scene.AddComponent(instanceInScene); needRecreateInstance = false; } }