Unity Android show Black screen using flutter_unity_widget package - android

AIM : To load specific element from unity 3D into flutter Android App.
Issue:
I am using flutter_unity_widget in flutter to show unity 3D content. I work fine until i use method like _unityWidgetController.postJsonMessage, It show black screen and content is not accessable.
current code in flutter
// Callback that connects the created controller to the unity controller
void onUnityCreated(controller) {
_unityWidgetController = controller;
unity(_unityWidgetController);
}
unity(UnityWidgetController _unityWidgetController){
_unityWidgetController.postJsonMessage("Model Selector" , "SelectModel", {"value" : 3});
_unityWidgetController.postMessage("Model Selector" , "SelectModel", "3");
}
flutter_unity_widget: ^2020.3.25

Black screen problem is related with Unity crash. I am working on a Flutter AR App. I am using Flutter + Unity + Vuforia and flutter_unity_widget: ^2022.1.0+2 version. Please try to find your Unity crash. I can share with you my working code example for sending messages from my Flutter App to Unity. I am using it for; when Unity is ready, send this message from Flutter to Unity:
void _onUnityCreated(controller) {
controller.resume();
_unityWidgetController = controller;
_unityWidgetController.postMessage("myUnityObject", "myUnityMethod", "myStringParam");
}

Related

Launch Flutter to Specific screen from Kotlin native side plugin

I have Flutter plugin
That shows fullscreen notification from background or when terminated using Push notification
This screen is built in Kotlin
and it has a button that when pressed
it launch the Main Intent of the application - the code in that plugin is the following
ACTION_CALL_ACCEPT -> {
saveCallState(callIdToProcess!!, CALL_STATE_ACCEPTED)
channel.invokeMethod("onCallAccepted", parameters)
var launchIntent = getLaunchIntent(context!!)
launchIntent?.action = ACTION_CALL_ACCEPT
context.startActivity(launchIntent)
}
this works fine and it launch the application to the default route
I want it to open specific screen instead , also if there is a way to pass the parameters to this screen
I don't know if this can be achieved with channel.invokeMethod
because this is in the plugin side , I cannot run Navigator inside it's Dart code (NO context available there)
I only know basics of Kotlin that's why I don't know how to achieve this properly
Thanks in advance .

Loading glb model in react native three using expo-three component not working on android device. The model appears on the web version though

I'm trying to create a react-native apps with three js using expo-gl, expo-three frameworks.
Following is the list of imports..
import { ExpoWebGLRenderingContext, GLView } from 'expo-gl';
import ExpoTHREE, { Renderer, TextureLoader } from 'expo-three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import * as React from 'react';
import {
AmbientLight,
HemisphereLight,
BoxBufferGeometry,
Fog,
GridHelper,
Mesh,
MeshStandardMaterial,
PerspectiveCamera,
PointLight,
Scene,
SpotLight,
Camera,
InstancedMesh,
} from 'three';
import OrbitControlsView from 'expo-three-orbit-controls';
Apart from the basic scene, camera and light setup I'm trying to load a glb model using the ExpoTHREE.loadAsync method as below...
const loadGlb = async ()=>{
const obj = await ExpoTHREE.loadAsync(
[require('./assets/suzanne.glb')],
null,
null}).
then((e)=>{
scene.add(e.scene);
e.scene.traverse((f)=>{if(f.isMesh){f.material = new THREE.MeshNormalMaterial();}});
})
.catch((err)=>{console.log(err)});
}
loadGlb();
Using the ref: https://www.npmjs.com/package/expo-three
The model loads when I run the code on the desktop browser but not on my android phone using expo app. Please let me know what am I doing wrong.
You can access the app here https://expo.io/#praful124/expo3
I had the same problem and ended up running into the fact that it does not support textures inside the glb file. But if you find a solution, I will be very happy if you share them.

How to make my Unity 3d (AR) project play in a full screen on my phone?

Testing Augmented Reality made with Unity 3d and vuforia on my android device is not showing in full screen !
I have tried to change everything in unity player settings but nothing changed
i even tried to do a script for the AR Camera
public class fullscreen : MonoBehaviour
{
// Start is called before the first frame update
void Start() =>
// Toggle fullscreen
Screen.fullScreen = !Screen.fullScreen;
// Update is called once per frame
void Update()
{
}
}
but it didnt work
I want to show it in the full screen
check my imageon Android device
If your game is in fullscreen Screen.fullScreen = !Screen.fullScreen; will make your game not fullscreen anymore. Use Screen.fullScreen = true;
Then, under Project Settings -> Player -> Resolution and Presentation check Start in fullscreen mode.

ionic android unexpected token

I am using the Ionic Framework to build a mobile app for Android/iOS. I was able
to build the project for android (ionic build android). When I run the app, it will be only a white screen, that's because there is an error (when you use GapDebug, you can run apps on your phone and you will be able to debug, and see errors). Now if I run it on the desktop browser there really is NO error and everything is working. Below is the error that is shown in GapDebug:
Now when you check the code in service.js line 394:
There's nothing wrong with the code right? If I try to change line 394 to something like key : self.currentUser, there will be NO error and the app will work. What seems to be the problem here?
Not sure why you are making an object's attribute a list? If you want the key to be childQuestionSnapshot.key then remove the square brackets.
If you are trying to update a list of objects, you can do something similar to the below:
var test = [{key: 'thisguy'},{key: 'thatguy'},{key: 'myguy'}]
test.forEach(function(item){
item['key']='newguy'
})
console.log(test)
Do this instead
var updateObj = {};
updateObj[childQuestionSnapshot.key] = self.currentUser;
applicantRef.update(updateObj, function() {
console.log("applicant answers updated");
});

Phonegap window.open does not work on Android

I have an iOS/Android app built on cordova 2.6 and jqm 1.3. I need to open a link to an external website after the user clicks on a button. The code I am using is:
var ref = window.open('http://google.com','_self','location=yes');
ref.addEventListener('loadstart',function(event) {
console.log('load started');
});
ref.addEventListener('loadstop',function(event) {
console.log('load stopped');
});
ref.addEventListener('loaderror',function(event) {
console.log('load error = ' + JSON.stringify(event));
});
On iOS everything performs like I would expect. A new browser window opens with the google website loaded. But I cannot get anything to to load in Android. When I click on the button, nothing happens. I have put in console statements before and after the window.open, so I know the code is at least being executed.
My config.xml should be wide open for white listed sites:
<access origin=".*"/>;
I have tested on a Nexus 7 (android 4.2) and an android 2.2 emulator with the same results on both.
Does anyone know why window.open would not be firing correctly on android?
It looked like it was a problem with 2.6 loading plugins on Android. I upgraded to 2.7 and everything started to work.
Perhaps it's a solution to use the ChildBrowser plugin? This gives you a bit more control over the operation itself, while still preserving platform compatibility between iOS and Android.
In most cases, I use something like the following snippet to use the childbrowser to display an external page.
function openBrowser(url) {
// determine if the childbrowser plugin is available
var useChildBrowser = ('plugins' in window && window.plugins.childBrowser);
if (useChildBrowser) {
popup = window.plugins.childBrowser;
popup.showWebPage(url, { showLocationBar: false, showAddress: false });
} else {
popup = window.open(url, 'Share', "['width=600px', 'height=400px', 'resizable=0', 'fullscreen=yes']");
}
}
Note that this falls back to using window.open if the ChildBrowser plugin isn't available, so you won't break anything else with this. Could be worth a shot, perhaps?

Categories

Resources