Some UI buttons work and other don't on Android - c#

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.

Related

How to add appstore view in my Unity iOS app?

I have seen some games having store page opens in-game as a native window without quitting the game at all.
I have search around and couldn't find anything related to it.
Is there a specific plugin to achieve that or how it can be exactly done? If not how can I add a store view in my Unity iOS game
Example from a random game on app store:
The screen above is inside a game, pressed "Download now" and it showed the other game store page as shown above without leaving the game itself. Pressing "Done" minimizes the popup and let you continue playing normally.

Unity LowLevel Touch Screen Detect android

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

How to create multiple rewarded video button with unityads

i implemented rewarded video ads(UnityAds) button and it works fine, but i don't know how to create another button that gives a completely different reward.
am not a unity developer but I might know a few things about unity.i would recommend you check the unity docs for rewarded video ads there must be an Advertisement.refresh method almost every ad network has it.

Is there a way to get the number of buttons a joystick has?

Introduction
I am making a game in Unity that was designed for the player to use all the letters on the keyboard. The game shows a battle between two fighters, prompts a key, and the player must mash that key for his character to push the other.
The fun part is that, eventually, the key to be pressed will change to another randomly.
This game is about learning the keyboard for those who haven't learned it, or haven't got used to their flashing new keyboard just yet.
I want the game itself to be playable in more ways, and I made a port to Android that works by touching the sides of the screen, there are flashing button panels that change as the keys would.
Issue
Now, the game has reached more that I want the game to be playable with controllers/gamepads/joysticks, but I'm afraid about two issues.
First and foremost: How can I tell the number of button inputs a controller has? I don't want my game to ask the player to press "JoystickButton19" when in their physical controller there are only 12 or so buttons.
I would add to the question "how do I know the actual name of the button itself?". In an example, how to know if the controller is a JoyCon. I noticed that in Fire Pro Wrestling World on Steam, the game recognizes the "SL" and "SR" buttons, so they got JoyCon specific layout there. If this question has to be answered in a new topic, I will make that.
This is my first question. Thanks in advance!

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.

Categories

Resources