Not able to create a toolkit Unity Engine component and run build

I know this is not the dedicated forum for the Unity Toolkit but I don’t know where else to ask, I’m creating a default type script and Engine component, (Just following the basic tut / documents) but I’m unable to export and run the build the error I get on the web console: BJS -: Unable to load from scenes/CameraTesting.babylon: Error in onSuccess callback

Anyone know what I’m doing wrong? Unity 2018.3 and toolkit: Babylon Editor Toolkit 2018-11 and Redist.

Code
/* Babylon Editor Script Component (C# UnityScript) */

using System;
using UnityEditor;
using UnityEngine;
using Unity3D2Babylon;

namespace MyProject
{
	public class TestEditorComponent : EditorScriptComponent
	{
        [Header("-Script Properties-")]

        [BabylonProperty]
        public string hello = "Hello World";

		protected TestEditorComponent()
		{
			this.babylonClass = "PROJECT.TestComponent";
		}
	}
}

typescript:

/* Babylon Mesh Component Template */
/// <reference path="../../Babylon/Library/babylon.manager.d.ts" />
/// <reference path="../../Babylon/Library/babylon.d.ts" />

module PROJECT {
    export class TestComponent extends BABYLON.MeshComponent {
        public constructor(owner: BABYLON.AbstractMesh, scene: BABYLON.Scene, tick: boolean = true, propertyBag: any = {}) {
            super(owner, scene, tick, propertyBag);
        }

        protected start() :void {
            console.log(this.getProperty<string>("hello"));
            // Start component function
        }
    }
}

Can you please send me the scene as a Unity package and i will debug thru WHAT is causing the project not to run. Its propobly something to do with the way project.js async loads ALL the SCRIPTS including the the runtime libraries… No i dont do this in the new version of the Babylon Toolkit… The GLTF loader itself SELF load just the project script bundle… the rest of the libraries should be already loaded on the HOST page.

But send me the project an i will try the find the problem using the OLD version of the toolkit :slight_smile:

1 Like

Thanks so much Mackey but the issue was my typescript Compiler, I have no idea why but I had to re install it, I might of had a older one or the wrong one.

I also changed my toolkit version to the redist version, I’m assuming that’s the most recent version? If not how would I get the new one you’re referring to?

New version still in Alplha and not ready … as soon as get enough issues addressed in new version I will put a preview version out

Btw… my new version was re written from ground up to produce the best GLTF scene file with extra metadata … that I can make. All aspectes of toolkit have been Refined and optimized for faster and cleaner workflows…

And all using the native Unity components… the only component in new version are optional and only necessary to change default values

If you like the current toolkit … you love the new one

1 Like

All I need for my current project is for components are:

Raycasting (OnMouseDown()) on a mesh
GUI for 4 buttons
Virtual controller for mobile

Would that be available in the Alpha, since it sounds much better?

1…
Simple Raycasting with the babylon engine do with the PICK WITH API… here is how my SceneManager wraps those those calls so i can easily say: BABYLON.SceneManager.RayCast(…)

        public static RayCast(scene:BABYLON.Scene, ray: BABYLON.Ray, predicate?: (mesh: BABYLON.AbstractMesh) => boolean, fastCheck?: boolean): BABYLON.PickingInfo {
            return scene.pickWithRay(ray, predicate, fastCheck);
        }

        public static MultiRayCast(scene:BABYLON.Scene, ray: BABYLON.Ray, predicate?: (mesh: BABYLON.AbstractMesh) => boolean): BABYLON.PickingInfo[] {
            return scene.multiPickWithRay(ray, predicate);
        }

2…
In Babylon you handle GUI with either HTML Elements… Not recommended though… Or you use the babylon GUI API: Use the Babylon GUI - Babylon.js Documentation

3…
Even in the version of the toolkit now… On the Default Scene Controller component… there is Config for Input. Just set Virtual Joy stick to Mobile or Always to have them for desktop as well… good for testing your joystick input:

00%20PM

That uses the babylon virtual joystick API…

Remember the toolkit (BOTH VERSIONS) is really just a fancy exporter… Once its exported out to a scene file (.babylon or .gltf) ITS ALL BABYLON CODE… you can easily attach script component to youe game objects so you can write all your game code right in the Unity Editor as if it where a native Unity Game… But you still use ALL Babylon API to do engine type stuff. The same exact code you would in your local projects or the playground… you just run in the context of a SCRIPT COMPONENT:

In the new toolkit this has been streamlined even more… Just one type of component a BABYLON.ScriptComponent … All your script class derive from this base call to provide all the life-cycle Unity style game development. Example HelloWorld PAIR of class (the toolkit also create the PAIR of class templates for you)

Example:

/**
 * Babylon Script Component
 * @class HelloWorld
 */
class HelloWorld extends BABYLON.ScriptComponent {
    private message:string;

    public constructor(entity: BABYLON.AbstractMesh, scene: BABYLON.Scene, properties: any = {}) {
        super(entity, scene, properties);

        // Get editor message property
        this.message = this.getProperty<string>("message", "Default Hello World");
    }

    protected start(): void {
        // Start render loop function
        console.log("The game object '" + this.entity.name + "' says: " + this.message);
    }

    protected update(): void {
        // Update render loop function
    }

    protected after(): void {
        // After render loop function
    }

    protected destroy(): void {
        // Destroy component function
    }
}

And its C# Counterpart that is used JUST to edit properties in the editor at design time:

using System;
using UnityEngine;
using UnityEditor;

/**
 * Editor Script Component
 * @class HelloWorld
 */
[AddComponentMenu("Scripts/My Project/HelloWorld")]
public class HelloWorld : EditorScriptComponent
{
	// Add Editor Properties To Script Component
	public string message = "Hello World";
}

Hope that helps :slight_smile:

3 Likes