-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix LOD can not work normally while node's active changed dynamically #15641
Conversation
Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -5258,8 +5258,14 @@
* @en Force LOD level to use.
* lodLevel @en The LOD level to use. Passing lodLevel < 0 will return to standard LOD processing. @zh 要使用的LOD层级,为负数时使用标准的处理流程
*/
forceLOD(lodLevel: number): void;
+ /**
+ * @en Force multi LOD level to use, This function is only called in editor.<br/>
+ * @zh 强制使用某几级的LOD,该接口只会在编辑器下调用。
+ * lodIndexArray @en The LOD level array. Passing [] will return to standard LOD processing. @zh 要使用的LOD层级数组,传[]时将使用标准的处理流程。
+ */
+ forceLODs(lodIndexArray: number[]): void;
onLoad(): void;
_onRemove(comp: Component): void;
onRestore(): void;
onEnable(): void;
|
cocos/3d/lod/lodgroup-component.ts
Outdated
@@ -609,6 +618,9 @@ export class LODGroup extends Component { | |||
|
|||
onDisable (): void { | |||
this._detachFromScene(); | |||
if (this._forceUsedLevel >= 0) { | |||
this.lodGroup.lockLODLevels([]); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to wrap it into a function to update lockedLODLevels of lodGroup.
cocos/3d/lod/lodgroup-component.ts
Outdated
@@ -628,6 +643,14 @@ export class LODGroup extends Component { | |||
/** | |||
* @engineInternal | |||
*/ | |||
protected _updateLockedLODLevels (): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forceLODs will use it, as it is defined outside the class of LODGroup
cocos/3d/lod/lodgroup-component.ts
Outdated
this.lodGroup.lockLODLevels(this._forceUsedLevels); | ||
} else { | ||
this.lodGroup.clearLockedLODLevels(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just invoke this.lodGroup.lockLODLevels(this._forceUsedLevels);
is enough.
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: