I've been looking for a way to stop Vuforia engine from tracking, and googleing didn't help at all.
I wanted to stop tracking when I found a tracker, and then resume trackng after an event (like a button click).
This is what I used to accomplish what you need. (:
TrackerManager.Instance.GetTracker<ImageTracker>().Stop();
TrackerManager.Instance.GetTracker<ImageTracker>().Start();
Finally Visual Studio's IntelliSense helped me with this. You can disable a tracker in a single line of code calling
TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER).Stop();
Similarly, to start it again
TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER).Start();
This code will disable the tracker
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.UnregisterTrackableEventHandler(this);
}
This code will enable the tracker
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour)
{
mTrackableBehaviour.registerTrackableEventHandler(this);
}
only this code will enable the tracker
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour){
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
May i know the reason for 2 seconds delay.the scanline delay two seconds initially during the load of the app.
Related
For about an hour ago a Debug Canvas started Instantiating on Play.
I've searched around on the internet but can't seem to find anything.
Are there by any chance some of you who might know how to disable it as it's taking up about half of the screen?
Edit:
I tried to install the project on another computer and it doesn't show up. So idk if it has anything to do with the project or Unity itself.
Image
Add this code to one of your scripts on Awake or Start:
UnityEngine.Rendering.DebugManager.instance.enableRuntimeUI = false;
This is mentioned in documentation
You have to be on CoreRP 12 or later as mentioned here
Try Left Ctrl + Backspace to toogle it, or remove the Universal RP (Render Pipeline) package or disable it by code:
bool debugupdater_disabled = false;
private void Update()
{
if (debugupdater_disabled)
return;
GameObject debugUpdater = GameObject.Find("[Debug Updater]");
if(debugUpdater != null)
{
Destroy(debugUpdater);
debugupdater_disabled = true;
Debug.Log("done");
}
}
Android 12 introduced the behavior where the last app you had active are continuing to run when inside the recent menu. I'm wondering if there's a flag or something to put in AndroidManifest file to prevent this behavior as it's conflicting with some logics in our app (which works fine for Android < 12). I've googled but it's hard to find unless you know exactly what this "feature" is called.
Steps:
Start app
Open recent menu
Observe that you can interact and that the app is still running as if you had it open/active
Why is this a problem? Because a user is now able to force quit the app (swiping it away) without entering the "paused" state in our game (using Unity) meaning some save logic won't run.
This can be worked around in one way or another, but for now I would like to just pause the app in recent menu if possible (our app has zero reason for being active in recent menu).
EDIT:
As #WyattL mentioned in his answer, android:excludeFromRecents="true" might work, but it will cause drop in playtime and retention of the game and would prefer to have a more proper solution to this "unnecessary" feature of Android 12.
I can't be sure without testing on every phone as it seems the issue varies by device (thanks Ruzihm), but if opening the Recent Apps screen generates an OnApplicationFocus() call, this would provide a solution.
In an active MonoBehaviour:
private void OnApplicationFocus( bool focus )
{
if( focus ) {
UnpauseLogic();
}
else {
PauseLogic();
SaveLogic();
}
}
(It might also be worth trying OnApplicationQuit() in case it's called on specific devices during a swipe termination, but in my own tests it was never called.)
According to some brief research, did you try adding
<activity>
...
android:excludeFromRecents="true"
android:label=""
...
</activity>
to the AndroidManifest.xml?
I was getting this error when I try to load my Web game:
My game is loaded at this domain:
Highest Flavor Website Link
This is my project settings at the time of build export:
Please give me some suggestion to solve this problem.
This error happened to me due to using the dynamic keyword. After replacing all my dynamic types with object the error was gone. Apparently the dynamic keyword is not supported on WebGL builds.
I've finally fixed the same error in my project. Here is what i did:
Narrow down the line of code that crashes WebGL.
Go through the painfull process of pinpointing the line of code that
is the source of the error. I had this "luck" that error occured
when I've hit button and tried to load UIScene in Addition mode. So
at first I found the script in the scene which when disabled got rid
of the crash. Then I've repeated the steps and digged deeper into
lines. After 2 hours of builds, comments etc I've found that the code
was not working was setting the new color for UnityEngine.UI.Image.
Which was pretty weird because in playmode everything worked ok.
Find solution. I think my solution might not be universal but I think there is something going in the Unity gameloop/lifecycle when running WebGL. The source of the problem was that i set the field that was storing my UI.Image in the Start method and then in some function I've tried to change the color.
Property was not exposed in inspector.
public class ModuleUI : MonoBehaviour
{
Image qualityBG;
void Start()
{
qualityBG = GetComponent<Image>();
}
...
then this line below was the cause of the crash
public void Set(Module module)
{
...
qualityBG.color = module.Quality.ToColor();
}
Fixing - so I've added [SerializeField] attribute to the field and set it up in editor, dragged the Image into the inspector slot. An it fixed it. I suspect that WebGL build might perform some methods in different order, or maybe the multipleScene loaded together might to do with it. I'm not sure but the field was not set properly with previous code fot WebGL build.
Bonus:
I've also fixed some issues that was not critical (not crushing WebGL game) but not working properly as expected in playmode. This also has got to do with trying to set some object in Start() method and then doing something on them. The collection was not set up (probably null) in WebGL.
EffectUI[] effects;
Start()
{
effects = GetComponentsInChildren<EffectUI>();
}
void HideAllEffects()
{
if (effects != null)
for (int i = 0; i < effects.Length; ++i)
effects[i].gameObject.SetActive(false);
}
And this also started working when I've added [SerializeField] to effects and hook it up in the scene...
Hope this will help some of you guys & gals!
To run this build within the web browser - I have removed all extra things related code those can't work within the web build like in-app purchase, advertisements, leaderboard, native sharing etc...
After these things code removed from the project, I uploaded the exported build content to my hosting. Then after it started working properly.
I have a main camera in my scene with a Sun Shafts (Script) ImageEffect on it.
[![enter image description here][1]][1]
(I'm using Medieval Environment asset.)
I'd like to disable this effect programmatically when main camera reaches a specific coordinate.
Please kkep in mind, that the script I'd like to disable is a .js script.
So here is my code:
foreach(Camera c in GameObject.FindObjectsOfType(typeof(Camera)))
{
if ((c.name == "Main Camera"))
{
if ((c.transform.position.x < -10))
{
//Disable Sun Shafts effect
}
}
}
How to disable Sun Shafts effect programmatically?
If you google "Unity3d disable a component" you will instantly find the answer
https://unity3d.com/learn/tutorials/modules/beginner/scripting/enabling-disabling-components
yourComponent.enabled = false;
For example this flawless answer by one of the best Unity engineers, is basically perfect
http://answers.unity3d.com/answers/26849/view.html
Note for example "If you see a checkbox in the Inspector, you can enable or disable it."
Note that here on StackOverflow you cannot change questions by editing them -- don't hesitate to ask new questions. Ask as many as you wish.
Is there a way to start a gwt-app in fullscreen mode (without toolbar, navigation)?
I found only a hint to open a new window:
Window.open("SOMEURL","SOMETITLE",
"fullscreen=yes,hotkeys=no,scrollbars=no,location=no,menubar=no,status=no,
toolbar=no,resizable=no");
Is this the only way?
If yes, what's the best way to use the "Window.open" (Example)?
This works for me:
private native void requestFullscreen() /*-{
var element = $doc.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}-*/;
This isn't really a GWT question - this is a browser-provided API that GWT happens to wrap for you.
It's worth noting that modern browsers have a tendency to ignore some or all of these flags. For example, good luck getting Chrome to hide its address bar. The reason for this is that if they honoured all of the flags, you could write a web app which looked exactly like a desktop app and the user wouldn't know it - which is exactly what you sound like you're trying to do!
or use https://github.com/wokier/gwt-fullscreen
Caffeinate response has been used as a basis. I also added an event to be notified of fullscreen state change.