Jump to content

Editor scripts and log into editor console


photo

Recommended Posts

Hello. I want write editor scripts and log into editor console.

I started with AppEditorLogic. But i don't see any log messages in console.

1. I think that i should write editor logic in AppEditorLogic class, right? But can i write Component script that will be execute some methods in editor (for example some Initialization or somenthing else)?

2. Why Log.Message don't visible in editor console?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Unigine;

namespace UnigineApp
{
	
	class AppEditorLogic : EditorLogic
	{
		// Editor logic, it takes effect only when the UnigineEditor is loaded.
		// These methods are called right after corresponding editor script's (UnigineScript) methods.

		public AppEditorLogic()
		{
		}

		public override bool Init()
		{
			// Write here code to be called on editor initialization.

			return true;
		}


		// start of the main loop
		public override bool Update()
		{
            // Write here code to be called on editor initialization.
            Log.Message("Editor update\n");

			return true;
		}

		public override bool Render()
		{
			// Write here code to be called before rendering each render frame when editor is loaded.
            Log.Message("Editor render\n");
			return true;
		}
		// end of the main loop

		public override bool Shutdown()
		{
			// Write here code to be called on editor shutdown.

			return true;
		}

		public override bool Destroy()
		{
			// Write here code to be called when the video mode is changed or the application is restarted (i.e. video_restart is called). It is used to reinitialize the graphics context.
	
			return true;
		}

		public override bool WorldInit()
		{
            // Write here code to be called on world initialization when editor is loaded.
	
			return true;
		}

		public override bool WorldShutdown()
		{
			// Write here code to be called on world shutdown when editor is loaded.
	
			return true;
		}

		public override bool WorldSave()
		{
			// Write here code to be called on world save when editor is loaded.
	
			return true;
		}
	}
}

 

Link to comment

Hi Vadim,

To execute your custom logic in Editor currently you have following options:

  1. UnigineScript
  2. C++ Plugin

This happens due to that fact that Editor is a standalone application (*.exe) and (0ccording to your code) your application is also a standalone C# app. They will not work simultaneously altogether.

A new type of project was introduced in 2.9 release (that uses .NET Core runtime) and uses new C# Component system inside Editor (the logic itself is also executed only when you press Play button inside Editor):

 

Quote

1. I think that i should write editor logic in AppEditorLogic class, right? But can i write Component script that will be execute some methods in editor (for example some Initialization or somenthing else)?

That currently is not possible to achieve. C# Component system (and C++ one) are not performing any actions inside the Editor.

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
10 hours ago, silent said:

Hi Vadim,

To execute your custom logic in Editor currently you have following options:

  1. UnigineScript
  2. C++ Plugin

This happens due to that fact that Editor is a standalone application (*.exe) and (0ccording to your code) your application is also a standalone C# app. They will not work simultaneously altogether.

A new type of project was introduced in 2.9 release (that uses .NET Core runtime) and uses new C# Component system inside Editor (the logic itself is also executed only when you press Play button inside Editor):

 

That currently is not possible to achieve. C# Component system (and C++ one) are not performing any actions inside the Editor.

Thank you. Yes, I use .Net core API. So do I can write any editor logic (and runtime logic) with UnigineScript when I use C# project? 

Edited by vadim.lisev
Link to comment

Hi Vadim,

So do I can write any editor logic (and runtime logic) with UnigineScript when I use C# project? 
On the one hand... Yes you can.
1) You can use WorldExpressions (Create [main menu] -> Logic -> Expression).
2) You can create WorldLogic UnigineScript (Create [asset browser] -> Create USC) and attach it to the world file.
But, on the other hand... You don't have any access to the Editor API (Undo/Redo, selections, asset browser, viewport, etc.)

Full support for plugins to the Editor in the development.

Best regards,
Alexander

Link to comment

Hello,

On 9/3/2019 at 7:35 AM, silent said:

That currently is not possible to achieve. C# Component system (and C++ one) are not performing any actions inside the Editor.

I think it is also possible (or at least it was possible) to register C++ Components from a C++ plugin. In that case the components should also be executed within the editor, is that correct?

(I'm assuming here that the editor.exe can still load C++ plugins). But for C# that is not possible, because the editor exe cannot load a C# plugin.

As much as I like the C# workflow of the Component System, having Components performing actions within the editor is a missing feature for me (i.e. how much sense does it make to expose a float as a slider in the editor if changing that slider does not immediately provide feedback to the (editor)user).

Cheers

Helmut

 

Link to comment

helmut.bressler

Thanks for the feedback :)

Yes, we know that there is a room for improvement in terms of C# and Editor interaction and we will continue to dig in that direction in the future updates.

Currently .NET Core is not supporting hot VM reload, so we can't use C# scripting inside Editor yet (theoretically we can, but the amount of time that would be required to implement this feature is huge and result will be buggy anyway).

Hope that with the current .NET Core progress required features may appear shortly.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hello Silent,

9 hours ago, silent said:

Yes, we know that there is a room for improvement in terms of C# and Editor interaction and we will continue to dig in that direction in the future updates.

I know that this is far from trivial and I think it is worth spending some time to search for the best solution, (which enables quick compile times, the possibility to attach a debugger and so on)

9 hours ago, silent said:

Currently .NET Core is not supporting hot VM reload, so we can't use C# scripting inside Editor yet (theoretically we can, but the amount of time that would be required to implement this feature is huge and result will be buggy anyway).

Hmm just thinking about it ... .NET Core does support loading of assemblies (=dlls) at runtime, but I would guess the problems are caused during reloading of an assembly, due to naming conflicts, in case the source code is modified but the classname stays the same. (It seems that some improvements are coming in .Net Core 3)

Anyways I'm happy to see that Unigine continues to invest into .NET :-)

Keep up good work.

Cheers

Helmut

Link to comment
×
×
  • Create New...