6 changed files with 28 additions and 6 deletions
@ -1,4 +1,6 @@
|
||||
#unityContainer{ |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
} |
||||
|
||||
|
@ -1,19 +1,36 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
|
||||
declare var UnityLoader: any; |
||||
declare var UnityProgress: any; |
||||
|
||||
|
||||
@Component({ |
||||
selector: 'app-unity', |
||||
templateUrl: './unity.component.html', |
||||
styleUrls: ['./unity.component.scss'] |
||||
}) |
||||
|
||||
|
||||
|
||||
export class UnityComponent implements OnInit { |
||||
|
||||
constructor() { } |
||||
public unityInstance: any = {}; |
||||
|
||||
constructor() { |
||||
window.GetName = this.GetName.bind(this); |
||||
} |
||||
|
||||
progressValue = 0; |
||||
|
||||
ngOnInit(): void { |
||||
UnityLoader.instantiate('unityContainer', 'assets/unityAppliction/Build/build.json', {onProgress: UnityProgress}); |
||||
this.unityInstance = UnityLoader.instantiate('unityContainer', 'assets/unityApp/Build/unityApp.json'); |
||||
this.SendMessage('UnityWebGL', 'GetName', ''); |
||||
} |
||||
|
||||
public GetName(): void { |
||||
console.log('这是Unity调用的Angular方法'); |
||||
} |
||||
public SendMessage(objectName: string, methodName: string, value: any): void { |
||||
console.log('=============================================='); |
||||
this.unityInstance.SendMessage(objectName, methodName, value); |
||||
} |
||||
} |
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue