Unity LowLevel Touch Screen Detect android - c#

I was Working on a new application on unity and i wanted to make the perfamonce good for phones so what i did is i killed the playerloop that's mean i switched to the lowlevel unsing unityengine.lowlevel (playerloop) but the problem is i can't detect any touches i tried everything :
button click (normal) - dosn't worked
event systems - dosn't worked
addlistener button - dosn't worked
mouse click on the update - dosn't worked
so i read some unity articles and everything in stackoverflow and i didn't find anything .
will i killed the playerloop because a developer named "Jon Manning" sad sow and he explained how to detect touches on iphone and he did say that detect touches on android is possible but he didn't say how you can see the video here to better understand : https://www.youtube.com/watch?v=C7CZyqHGKXw&t=1812s
so if anuone can help i will be very greatfull

I personally have created an Android app before, and the easiest way to detect touches on Android phones are with these functions:
private void OnMouseDrag() { // called every frame the user has their finger held down while touching the collider or GUI element }
private void OnMouseDown() { // called when the user presses the collider with their finger }
They work perfectly for single-touch applications, if you want multi-touch capability there are other methods you can use.
The only caveat is that these functions are only called when the user's finger touches the collider, so every object you want to have interacted with must have a collider attached, along with this script.
There are also other OnMouse functions which you can look up on the Unity Docs, if you want more control.

I don't Really understand Why unity realised the UnityEngine.lowlevel if there is no way to keep using the app or the game ones you kill the playerloop ,Will i know that it work on ios but What about android i think android is really important than ios because there is like 7% of the world using ios and the rest using android ,Will i know that the propably 7% are reach but i thnik that is not good reason
I will be using android studio and java for my app , and i hope unity team will do something about that and if anyone searching how to wake up from the lowlevel if you're not building for ios don't bother you're self go create plugin if possible or just don't use the low level and of course google play will not give you a nice number of downloads because of the perfamonce and the battery , unity is only for games stick with that i already made a lot of apps non of them got more than 10k downloads because of the perfamonce and the battery

Related

Some UI buttons work and other don't on Android

I am making an Android game and in my game I have probably around 20 UI buttons, maybe more. I have buttons that do in-app purchases and then just normal buttons. All of my buttons work except 3.
The 3 of them worked the other day but then just stopped and I am not sure what I changed. I have deleted the buttons and added them back in, that didn't work. I have duplicated a button that does work and tried using that and that doesn't work.
The weird thing is, when I do everything in Unity everything works, it is just when I export it to my phone through internal testing through Google Play. When I do that it is when those 3 buttons stop working.
I downloaded LDPlayer which is just an emulator for a phone. When I run my game on there two of the buttons work, the two that pull up the leaderboards and achievements, but the third doesn't. The third button has audio attached to it and plays when touched. The two button with a script attached to them call the code below when pressed. I am connected to Google Play Services and my account does log in when the game launches. I have to in app purchase buttons that work just fine so I know that it isn't me not being able to connect to the Google Services.
public void ShowLeaderboard()
{
Social.ShowLeaderboardUI();
Debug.Log("Pushed the leaderboard button.");
}
and
public void ShowAchievementUI()
{
Social.ShowAchievementsUI();
Debug.Log("pushed achievement button");
}
Like I said everything worked on an earlier version of my game, these functions haven't changed at all. My whole PlayGameServices Class hasn't changed at all since I created it and everything worked in the beginning.
If anyone can point me in the right direction I would greatly appreciate it. I have tried doing some Google searches and they said to go to the eventsystem and make sure that "force module active" was checked. I have made sure that script execution order was correct. I know the buttons are detecting my finger press because I have it change sprites on press and all three buttons are responding to the touch. I really don't know what else to do at this point. Thank you in advance.

Unity LogitechSDK cannot detect my G29 Steering wheel

I try to develop a driving simulator, I started with G27 steering wheel and everything works fine with LogitechSDK in Unity. But when I switch to G29, the SDK seems cannot detect the steering wheel. But by using Unity default crossplatform control, I can see Unity take the input from G29 just fine.
No Connection from SDK Picture
But Unity can detect disconnection and reconnection
I can't understand what happened here.
I can't solve your problem but would just like to share my experience in case it helps.
About a year ago, I too tried to build a driving simulator in Unity using the G29. I was able to obtain input from the G29. Some steps I took were to ensure that the Logitech Gaming Software application was installed and running, and to set up the InputManager for the joystick (you'll need to map out the controls).
However, I was unable to get the force-feedback to work, due to a bug on Logitech's part (I managed to contact their tech support, who was also unable to solve it). I haven't since been following the news of whether they've managed to fix it, perhaps you'd know (:

Detect when user takes a screenshot in Unity

So in this maze kind of game I'm making, I will show the maze to the player for 30 seconds.
What I don't want is that the player taking screenshot of the maze.
I want to do something like Snapchat, or Instagram, how it detects when you take a screenshot of a snap/story.
I'm using C#. It can also prevent user to take screenshot. I don't mind.
Is there a possible way to detect when the user takes screenshots or prevent it in Unity?
No, you can't detect this reliably. They also could make a photo with a digi cam. Furthermore there are endless ways to create a screenshot and the os has no "callback" to inform an application about that. You could try to detect the "print screen" key but as I said there are other screenshot / screen recording tools which could use any hotkey or no hotkey at all. I have never used Snapchat but it seems it's not safe either.
There are even monitors and video projectors which have a freeze mode to keep the current image. You could also run your browser in a virtual machine. There you can actually freeze the whole virtual PC or take screen shots from the virtual screen and an application running inside the VM has no way to even detect or prevent that.
I once had to do something similar. If you just want to do what snapchat did then it can be done but remember that as long as the app is running on anyone's device instead of your server, it can be de-compiled, modified and compiled again so this screenshot detection can be circumvented.
First of all you need to know this about Apple's rule:
2.5.9 Apps that alter or disable the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, or other native
user interface elements or behaviors will be rejected.
So, the idea of altering what happens when you take a screenshot is eliminated.
What you do is start the game, do the following when you are showing the show the maze to the player for 30 seconds:
On iOS:
Continuously check if the player presses the power and the home button at the-same time. If this happens, restart the game and show the maze to the player for 30 seconds again. Do it over and over again until player stops doing it. You can even disconnect or ban the player if you detect power + the home button press.
On Android:
Continuously check if the player presses the the power and volume down buttons at the-same time. Perform the-same action described above.
You cannot just do this with C#. You have to use make plugins for both iOS and Android devices. The plugin should use Java to the the detection on android and Object-C to do the detection for iOS. This is because the API required is not available in C#. You can then call the Java and Objective-C functions from C#.
Other improvement to make:
Check or external display devices and disable them when you are
showing the maze to the player for 30 seconds. Enable them back
during this time.
When you detect the screenshot button press as described above,
immediate take your own screenshot too. Loop through images on the player's picture gallery and load all the images taken that day.
Compare it with the screenshot you just took and see if they match.
If they do, you are now very sure that the player is trying to cheat.
Take action like banning the player, restarting the game or even
trolling the player by sending their screenshot to the other player. You can also use it as a proof to show that the user is cheating when they complain after being banned.
Finally, you can even go deeper by using OpenCV. When you are
showing the player the maze for 30 seconds, start the front camera of
the device and use OpenCV to continuously check if any object other
than the player's head is in front of the camera. If so, then the
player is trying to take a screenshot with another device. Take
action immediately. You can use machine language to train this.
How far to go depends on how much time you want to spend and how much you care about player's cheating online. The only thing to worry about is players de-compiling the game and removing those features but it is worth implementing.
My Android phone takes screenshots differently. I swipe down from the
top of the screen and select the "Capture" option.
Nothing is always the-same on Android. This is different on some older or different Android devices. You can detect swipe patterns on the screen. The best way to do this is to build a profile that handles each Android device from different manufactures.
For those commenting, this is possible to do. You must do it especially if it is a multiplayer game. Just because a game can be hacked does not mean that a programmer should not implement basic hack prevention mechanism. Basic hack prevention mechanism should be implemented then improved as you get feedback from players.

Windows Phone turn flash on in background

I am working on a tools app and I need a way to turn on the camera flash when I click a tile, then keep it on in the background and turn it off once I click the tile again.
I don't need any help with the tile yet all I want to know is what I can do to turn on the flash and then keep it on. All the examples I have seen thus far simply pretend to be a camera and then turn the flash on.
Do you know of anything?
PS. I am planning on making this for WP 7 and 8 but if you know of a way that will on work on WP 8 that will also help me a lot.
The simple answer is no.
While the app is running, you can control the camera and turn on the flash. But as soon as you exit the app (Back button) or the app is suspended (due to a phone call or by pressing the Start button), the use of the camera is suspended.
Windows Phone does have Background Agents but these are very limited and do not allow access to the camera API at all (and many other APIs).

Implementing playlists with songs from phone storage [windows phone]

I have been struggling with an issue with my media player windows phone (7) application. The problem is that I can't seem to implement playlists.
What I want to do is play songs from the media library. This article seems pointless.
I've tried getting into the SongCollection class and figure out how to create more of these things. It appears to be impossible (no constructor, can't cast it, can't inherit it).
After that I tried getting an object on the process running the background audio agent that existed in my app (until I discovered it was redundant), and feed the media player one song at a time.
Problem is, I don't know when the media player stopped playing. It works ok as long as my app is in the foreground, but when it is not, everything stops working, only the media player keeps going.
Is there a way I haven't figured out? In the article above they suggest there is a link between the Zune Media Queue, which I presume is the MediaPlayer.Queue property, and various things I can implement, but I just can't figure a way to make it go.
You should give up since building your own media player is an impossible mission (been there, done that). You cannot create playlists or edit any information, you cannot replace default event handlers for on-screen music controls, you don't get events for music change in your application unless it is currently running.
Basically, it is really limited in what you can do right now and the situation isn't much better with WP8.
I hope that it will be less read-only by the time we get Windows Phone 9.
Take a look at the UWP samples from Microsoft:
https://github.com/Microsoft/Windows-universal-samples
The sample contains play/pause/playlists explanation.
This was already possible in Windows phone 7.5/8/8.1

Categories

Resources