mirror of
				https://github.com/szrpf/SceneAdapterDemo
				synced 2025-11-04 05:15:56 +00:00 
			
		
		
		
	v1.2
This commit is contained in:
		@@ -122,7 +122,7 @@
 | 
				
			|||||||
        1,
 | 
					        1,
 | 
				
			||||||
        1,
 | 
					        1,
 | 
				
			||||||
        1,
 | 
					        1,
 | 
				
			||||||
        1
 | 
					        0.31666666666666665
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "_eulerAngles": {
 | 
					    "_eulerAngles": {
 | 
				
			||||||
@@ -643,7 +643,7 @@
 | 
				
			|||||||
      "width": 1080,
 | 
					      "width": 1080,
 | 
				
			||||||
      "height": 1920
 | 
					      "height": 1920
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "_fitWidth": true,
 | 
					    "_fitWidth": false,
 | 
				
			||||||
    "_fitHeight": false,
 | 
					    "_fitHeight": false,
 | 
				
			||||||
    "_id": "6d1ebIvmZJPqKflif+HTsU"
 | 
					    "_id": "6d1ebIvmZJPqKflif+HTsU"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@@ -655,6 +655,6 @@
 | 
				
			|||||||
      "__id__": 2
 | 
					      "__id__": 2
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "_enabled": true,
 | 
					    "_enabled": true,
 | 
				
			||||||
    "_id": "e7Qc+zZkdDeabOFueN7izj"
 | 
					    "_id": "b6/k9iZ/BOq7igiEs0QR6w"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
@@ -9,8 +9,20 @@ const { ccclass, menu } = cc._decorator;
 | 
				
			|||||||
@ccclass
 | 
					@ccclass
 | 
				
			||||||
@menu('Comp/SceneAdapter')
 | 
					@menu('Comp/SceneAdapter')
 | 
				
			||||||
export default class SceneAdapter extends cc.Component {
 | 
					export default class SceneAdapter extends cc.Component {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    protected onLoad() {
 | 
					    protected onLoad() {
 | 
				
			||||||
 | 
					        let cvs = this.node.getComponent(cc.Canvas);
 | 
				
			||||||
 | 
					        if (cvs === null) {
 | 
				
			||||||
 | 
					            cc.warn(`节点${this.node.name}没有cc.Canvas组件, SceneAdapter添加失败!`);
 | 
				
			||||||
 | 
					            this.destroy();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (cvs.designResolution.width < cvs.designResolution.height) {
 | 
				
			||||||
 | 
					            cvs.fitWidth = true;
 | 
				
			||||||
 | 
					            cvs.fitHeight = false;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            cvs.fitWidth = false;
 | 
				
			||||||
 | 
					            cvs.fitHeight = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        this.resize();
 | 
					        this.resize();
 | 
				
			||||||
        cc.view.setResizeCallback(this.resize.bind(this));
 | 
					        cc.view.setResizeCallback(this.resize.bind(this));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -28,4 +40,4 @@ export default class SceneAdapter extends cc.Component {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								creator.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								creator.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -21038,7 +21038,7 @@ declare namespace cc.AssetManager {
 | 
				
			|||||||
		bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err));
 | 
							bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err));
 | 
				
			||||||
		``` 
 | 
							``` 
 | 
				
			||||||
		*/
 | 
							*/
 | 
				
			||||||
		load<T extends cc.Asset>(paths: string, type: { prototype: T } onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
 | 
							load<T extends cc.Asset>(paths: string, type: { prototype: T }, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
 | 
				
			||||||
		load<T extends cc.Asset>(paths: string[], type: { prototype: T }, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
 | 
							load<T extends cc.Asset>(paths: string[], type: { prototype: T }, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
 | 
				
			||||||
		load<T extends cc.Asset>(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
 | 
							load<T extends cc.Asset>(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
 | 
				
			||||||
		load<T extends cc.Asset>(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
 | 
							load<T extends cc.Asset>(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,18 +9,18 @@
 | 
				
			|||||||
    "default"
 | 
					    "default"
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
 | 
					  "start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
 | 
				
			||||||
  "design-resolution-width": 960,
 | 
					  "design-resolution-width": 0,
 | 
				
			||||||
  "design-resolution-height": 640,
 | 
					  "design-resolution-height": 0,
 | 
				
			||||||
  "fit-width": false,
 | 
					  "fit-width": false,
 | 
				
			||||||
  "fit-height": true,
 | 
					  "fit-height": false,
 | 
				
			||||||
  "use-project-simulator-setting": false,
 | 
					  "use-project-simulator-setting": false,
 | 
				
			||||||
  "simulator-orientation": false,
 | 
					  "simulator-orientation": false,
 | 
				
			||||||
  "use-customize-simulator": false,
 | 
					  "use-customize-simulator": true,
 | 
				
			||||||
  "simulator-resolution": {
 | 
					  "simulator-resolution": {
 | 
				
			||||||
    "width": 960,
 | 
					    "width": 960,
 | 
				
			||||||
    "height": 640
 | 
					    "height": 640
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "last-module-event-record-time": 1691731715153,
 | 
					  "last-module-event-record-time": 1695092167763,
 | 
				
			||||||
  "assets-sort-type": "name",
 | 
					  "assets-sort-type": "name",
 | 
				
			||||||
  "facebook": {
 | 
					  "facebook": {
 | 
				
			||||||
    "enable": false,
 | 
					    "enable": false,
 | 
				
			||||||
@@ -31,5 +31,7 @@
 | 
				
			|||||||
    "audience": {
 | 
					    "audience": {
 | 
				
			||||||
      "enable": false
 | 
					      "enable": false
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  },
 | 
				
			||||||
 | 
					  "preview-port": 7456,
 | 
				
			||||||
 | 
					  "clear-simulator-cache": true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user