Skip to content

How to make a USceneComponent editable in details panel? #111

@arthursw

Description

@arthursw

I tried the following code but the component is not editable:

let Compile = function(x) {  
    return require('uclass')()(global, x);
}

class CustomComponent extends MeshComponent {
    ctor() { }

    properties() { }
}

let CustomComponentClass = Compile(CustomComponent)

class CustomActor extends Actor {

    ctor() {
        console.log("CustomActor ctor")

        this.Root = SceneComponent.CreateDefaultSubobject("ActorRootComponent")
        this.SetRootComponent(this.Root)

        this.CustomComponent = CustomComponentClass.CreateDefaultSubobject("CustomComponent")
        this.CustomComponent.AttachTo(this.Root)
    }

    properties() {
        this.CustomComponent /*EditableAnywhere+Category:Javascript:CustomComponent*/;
    }
}

const CustomActorClass = Compile(CustomActor)

function initialize() {
    global.World = Engine.GetEditorWorld()
    global.CustomActor = new CustomActorClass(global.World, { X: 0 })
    return function () { $execEditor(function () { if(global.CustomActor.IsValid()) { global.CustomActor.DestroyActor(); } }) }
}

module.exports = function () {
    let bye
    let alive = true
    process.nextTick(function () {
        if (!alive) return
        bye = initialize()
    })
    return _ => {
        alive = false 
        if (bye) {            
            bye()
        }
    }
}

I would like the component to be editable in order to change the materials applied to it.

Is it possible to change the Object Flags at runtime, or elsewhere (outside the properties() function)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions