Jump to content

[SOLVED] Public variables not exposed in Editor


photo

Recommended Posts

Hello everyone!

I am having difficulties regarding exposing things in the editor. When I make a public variable it is supposed to show up in the editor, but it never does. And it doesn't work no matter the type of variable.

Here's the code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Unigine;

[Component(PropertyGuid = "9d726b584d9b76d7b9aca64ab1aee121ec3c880c")]
public class TowerSpawnUI : Component
{
	public Mesh CubeMesh;

	private void Init()
	{
		Gui GUI = Gui.Get();

		WidgetButton Btn = new WidgetButton(GUI, "Click Me!");
		Btn.AddCallback(Gui.CALLBACK_INDEX.CLICKED, new Widget.Callback0Delegate(BtnClicked));
		GUI.AddChild(Btn);
	}

	void BtnClicked()
	{
		new Mesh(CubeMesh);
	}
}

Here's what shows up in the editor:

image.png.f57d670e5fd6cd395a455e46537e4c0a.png

Link to comment

Hello,

Not all types of variables can be displayed in the editor. You can find all available options in C# Component Samples in the script csharp_component_samples/Components/components/ComponentParameters.cs. In your case with a mesh, you can use the asset link:

[ParameterAsset (Filter = ".mesh")]
public AssetLink CubeMeshLink;

and then create a mesh:

Mesh mesh = new Mesh (CubeMeshLink.Path);

 

Link to comment

Thank 

7 minutes ago, karpych11 said:

Hello,

Not all types of variables can be displayed in the editor. You can find all available options in C# Component Samples in the script csharp_component_samples/Components/components/ComponentParameters.cs. In your case with a mesh, you can use the asset link:


[ParameterAsset (Filter = ".mesh")]
public AssetLink CubeMeshLink;

and then create a mesh:


Mesh mesh = new Mesh (CubeMeshLink.Path);

 

Thank you for replying!

But, sadly, this isn't working for some reason. Even with simple things such as Integers and Floats (Which I know already have an inspector thing built in).

Here's, again, what the code looks like and the Editor

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Unigine;

[Component(PropertyGuid = "9d726b584d9b76d7b9aca64ab1aee121ec3c880c")]
public class TowerSpawnUI : Component
{
	[ParameterAsset(Filter = ".mesh")]
	public AssetLink CubeMesh;
	public int Test;

	private void Init()
	{
		Gui GUI = Gui.Get();

		WidgetButton Btn = new WidgetButton(GUI, "PooPoo");
		Btn.AddCallback(Gui.CALLBACK_INDEX.CLICKED, new Widget.Callback0Delegate(BtnClicked));
		GUI.AddChild(Btn);
	}

	void BtnClicked()
	{
		Mesh mesh = new Mesh(CubeMesh.Path);
	}
}

image.png.2c0eb571d8832e12d0a3707038e2553e.png

Link to comment

Could you please show us your data folder contents in Asset Browser? If everything is OK you will see only the single .cs file:

image.png

If you have some additional .prop files it would mean that something bad is happens. Engine log file can be also useful to see (you can get it from <Project_Dir>/bin/log.html).

That's how your component is looking in my case - new component was created via Editor (and I didn't replaced the auto-generated GUID when copied your code):
image.png

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

Link to comment

Sure, here's what it looks like in my editor (Though, from looking at your screenshot, the only thing I think could make a difference is the CS Template)

image.thumb.png.d1263a238af9d606b27737ddebfa9e2b.png

image.thumb.png.10ff7f89a89822e6c0c28e97d8cbf895.png

image.thumb.png.f3592296a9c33fbddc061460db7061cb.png

I also had a look through my log, And when looking through the log, there was 3 missing GUIDs, however, the code was still running fine and all the GUI stuff loaded at Runtime.

Here's the log file just in case you want to have a read:log.html

 

Edited by SeaPeaMe
Link to comment

I can see the issue (it's really stupid, btw). Could you please open generated .csproj file in the root directory of your project and replace all the:

<AssemblyName>Physics Sandbox</AssemblyName>

with

<AssemblyName>Physics_Sandbox</AssemblyName>

Here how it looks like on my PC:
image.png

After that simply reimport .cs component and everything should work fine. We will fix this bug in the upcoming SDK update.

Thanks!

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

Link to comment

I have replaced those things in the "Physics Sandbox.csproj" file, and it still isn't working!

If you want I can email you the project so you can have a deeper look into it.

Link to comment
  • silent changed the title to [SOLVED] Public variables not exposed in Editor
×
×
  • Create New...