cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

Improve array property view

Open ze0nni opened this issue 1 year ago • 5 comments

Use Case

image

When I collaps array property item I see only class name

Problem Description

Its hard to navigate in a large array property.

Proposed Solution

How about display user defined data instead class name?

@ccclass('AppViewPrefab')
class AppViewPrefab {
    @property(CCString)
    @displayName // << like this
    readonly id: string = "";
    @property(Prefab)
    readonly prefab!: Prefab;

    // << like this
    toString() { return id; }
}

@property([AppViewPrefab])
private prefabs: AppViewPrefab[] = [];

How it works

No response

Alternatives Considered

I think I can write custom editor for every list, but its not optimal

Additional Information

No response

ze0nni avatar May 22 '24 05:05 ze0nni

Hello, can you tell me what the purpose is for displaying the name you need for yourself?

wuzhiming avatar May 24 '24 06:05 wuzhiming

Sometimes I have list items with many properties image

I want to collapse the list to find element easier image

ze0nni avatar May 24 '24 08:05 ze0nni

You have so much data, why not save it as a JSON file

wuzhiming avatar May 24 '24 08:05 wuzhiming

Bad example. This is not game configs.

Typically this list closely associated with prefab nodes tree and contains refs to components.

enum AppButtonPhase {
    Normal = 0,
    Hover = 1,
    Pressed = 2,
    Disabled = 3,
}
Enum(AppButtonPhase);

@ccclass('AppButtonFaces')
class AppButtonFaces {
    @property({ type: AppButtonPhase })
    phase: AppButtonPhase = AppButtonPhase.Normal;

    @property(Node)
    target!: Node;

    @property(CCBoolean)
    active: boolean = true;
    
    @property(CCFloat)
    scale: number = 1;

    @property(Vec2)
    offsetX: Vec2 = Vec2.ZERO

    @property(Color)
    color: Color = Color.WHITE;
}

@ccclass('AppButton')
export class AppButton extends Component {
    @property([AppButtonFaces])
    private faces: AppButtonFaces[] = [];
}

image image

I can turn AppButtonFaces into Component. But its looks like overengineering.

ze0nni avatar May 24 '24 09:05 ze0nni

oke, I understand your feature. We will discuss it further.

wuzhiming avatar May 24 '24 10:05 wuzhiming