Merge branch 'Patrick' into darrel
This commit is contained in:
commit
4c0766a0b6
37 changed files with 2294 additions and 114 deletions
Binary file not shown.
BIN
MoCha/Assets/Prefabs/Progress Bars & Text.prefab
Normal file
BIN
MoCha/Assets/Prefabs/Progress Bars & Text.prefab
Normal file
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 441f50f7e865a4e9c937038cedf667ee
|
||||
timeCreated: 1524703581
|
||||
guid: 5b086532012024c1d89b53fd7a7a004c
|
||||
timeCreated: 1525034977
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
Binary file not shown.
BIN
MoCha/Assets/Scenes/FitbitLogin.unity
Normal file
BIN
MoCha/Assets/Scenes/FitbitLogin.unity
Normal file
Binary file not shown.
9
MoCha/Assets/Scenes/FitbitLogin.unity.meta
Normal file
9
MoCha/Assets/Scenes/FitbitLogin.unity.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4e05e44213ffe141906009c29238b2e
|
||||
timeCreated: 1525379963
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -18,7 +18,7 @@ namespace Assets.Scripts.Fitbit
|
|||
private const string _consumerSecret = "69307b9f332caf9946ef4e23cabde2e4";
|
||||
private const string _clientId = "22CX4L";
|
||||
private const string _callbackURL = "http://localhost/callback";
|
||||
private const string CustomAndroidScheme = "mocha://";
|
||||
private const string CustomAndroidScheme = "http://localhost/callback";
|
||||
|
||||
private const string _tokenUrl = "https://api.fitbit.com/oauth2/token";
|
||||
private const string _baseGetUrl = "https://api.fitbit.com/1/user/-/";
|
||||
|
@ -73,6 +73,7 @@ namespace Assets.Scripts.Fitbit
|
|||
{
|
||||
_bFirstFire = false;
|
||||
}
|
||||
GUI.Label(new Rect(10, 10, 100, 20), "Calories: " + _fitbitData.CurrentCalories);
|
||||
}
|
||||
|
||||
public void LoginToFitbit()
|
||||
|
|
|
@ -7,32 +7,56 @@ using UnityEngine.UI;
|
|||
using System.Text;
|
||||
|
||||
//Pretty much a copy of GetData...
|
||||
namespace PedometerU.Tests {
|
||||
namespace PedometerU.Tests
|
||||
{
|
||||
|
||||
public class GetGoals : MonoBehaviour
|
||||
{
|
||||
// For HTTP requests to the server.
|
||||
private MochaParser mp;
|
||||
|
||||
// Goals Progress Bar
|
||||
public Image pbbg;
|
||||
public Image pbf;
|
||||
|
||||
// My Goal Progress Bar
|
||||
public Image mgpbbg;
|
||||
public Image mgpbf;
|
||||
|
||||
// Monster Progress Bar
|
||||
public Image mpbbg;
|
||||
public Image mpbf;
|
||||
|
||||
public class GetGoals : MonoBehaviour {
|
||||
|
||||
public Image background;
|
||||
public Image fill;
|
||||
private string[] items = { "circle_eye", "crazy_hair", "circle_head", "gap_mouth", "pig_nose", "crown" };
|
||||
|
||||
// Display Text
|
||||
public Text rivalText;
|
||||
public Text goalText;
|
||||
public string currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
public string goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
public Text stepText;
|
||||
public Text pointsText;
|
||||
public Text remainingText;
|
||||
|
||||
// Goal information.
|
||||
private string currentDayStr;
|
||||
private string goalDayStr;
|
||||
public string prefKey;
|
||||
|
||||
// Used for time calculation.
|
||||
private int timeUsed;
|
||||
private int timeRemaining;
|
||||
private const int secondsperday = 86400;
|
||||
|
||||
//Progress Bar...
|
||||
public float barDisplay; //current progress
|
||||
private float barDisplay; //current progress
|
||||
//private Vector2 barPos;
|
||||
// This gets overwritten later by the background's size values.
|
||||
private Vector2 barSize = new Vector2(5000, 10);
|
||||
|
||||
//Pedometer
|
||||
private Pedometer pedometer;
|
||||
int userSteps;
|
||||
int userPoints;
|
||||
//double userDistance;
|
||||
int stepsGoal = 100;
|
||||
public Text stepText;
|
||||
public Text pointsText;
|
||||
public int stepsGoal;
|
||||
private int savedSteps;
|
||||
private int savedPoints;
|
||||
|
||||
|
@ -58,121 +82,168 @@ namespace PedometerU.Tests {
|
|||
|
||||
void Start ()
|
||||
{
|
||||
fill.type = Image.Type.Filled;
|
||||
fill.fillMethod = Image.FillMethod.Horizontal;
|
||||
fill.type = Image.Type.Sliced;
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
// This should later only get called per goal
|
||||
StartCoroutine(updateRival());
|
||||
}
|
||||
|
||||
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
||||
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
||||
// Create a new pedometer
|
||||
pedometer = new Pedometer(OnStep);
|
||||
// Reset UI
|
||||
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
if(PlayerPrefs.HasKey("totalPoints"))
|
||||
{
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetInt("totalPoints", 0);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
stepText.text = savedSteps.ToString () + "/" + stepsGoal.ToString();
|
||||
|
||||
if(prefKey == "daily")
|
||||
if(PlayerPrefs.HasKey("totalPoints"))
|
||||
{
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetInt("totalPoints", 0);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
}
|
||||
|
||||
{
|
||||
if(PlayerPrefs.HasKey("goalDate"))
|
||||
{
|
||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetString("goalDate",
|
||||
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||
}
|
||||
goalText.color = new Color(0f, 0f, 0f);
|
||||
}
|
||||
userSteps = savedSteps;
|
||||
userPoints = savedPoints;
|
||||
|
||||
//OnStep(savedSteps, 0);
|
||||
//OnStep(savedSteps, 0); //necessary?
|
||||
Debug.Log(savedSteps);
|
||||
|
||||
Debug.Log(pbbg.rectTransform.anchoredPosition.x.ToString() + " " + pbbg.rectTransform.anchoredPosition.y.ToString());
|
||||
|
||||
//goalText.text = prefKey;
|
||||
goalText.color = new Color(0f, 0f, 0f);
|
||||
Debug.Log(background.rectTransform.anchoredPosition.x.ToString() + " " + background.rectTransform.anchoredPosition.y.ToString());
|
||||
|
||||
//barPos = new Vector2(background.transform.position.x, 1895 - background.transform.position.y);
|
||||
//barPos = new Vector2(pbbg.transform.position.x, 1895 - pbbg.transform.position.y);
|
||||
|
||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
Debug.Log(goalDayStr);
|
||||
|
||||
if(prefKey == "daily")
|
||||
savePersistantGoalDate("daily");
|
||||
}
|
||||
|
||||
|
||||
//Texture the progress bar using these parameters
|
||||
public Texture2D emptyTex;
|
||||
public Texture2D fullTex;
|
||||
|
||||
//on a button press? begin a goal?
|
||||
void startGoal()
|
||||
{
|
||||
}
|
||||
|
||||
void savePersistantGoalDate(string key)
|
||||
{
|
||||
PlayerPrefs.SetString(key, goalDayStr);
|
||||
}
|
||||
|
||||
bool checkNewDay(string key)
|
||||
{
|
||||
string checkDay = PlayerPrefs.GetString(key);
|
||||
if(checkDay == currentDayStr)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
void OnGUI() {
|
||||
Debug.Log (background.rectTransform.rect.width);
|
||||
barSize = new Vector2 (background.rectTransform.rect.width, background.rectTransform.rect.height);
|
||||
//draw the background:
|
||||
GUI.BeginGroup(new Rect(barPos.x, barPos.y, barSize.x, barSize.y));
|
||||
GUI.Box(new Rect(0,0, barSize.x, barSize.y), emptyTex);
|
||||
|
||||
//draw the filled-in part:
|
||||
GUI.BeginGroup(new Rect(0,0, barSize.x * barDisplay, barSize.y));
|
||||
GUI.Box(new Rect(0,0, barSize.x, barSize.y), fullTex);
|
||||
GUI.EndGroup();
|
||||
GUI.EndGroup();
|
||||
}
|
||||
*/
|
||||
|
||||
// Was used for testing.
|
||||
//private float tempcounter = 0.1f;
|
||||
private float tempcounter = 0.1f;
|
||||
|
||||
// Call this to update the goals progress bar.
|
||||
public void updateProgressBar()
|
||||
{
|
||||
//Debug.Log (background.rectTransform.rect.width + " " + background.rectTransform.rect.height);
|
||||
barSize.x = background.rectTransform.rect.width;
|
||||
barSize.y = background.rectTransform.rect.height;
|
||||
//Debug.Log (pbbg.rectTransform.rect.width + " " + pbbg.rectTransform.rect.height);
|
||||
barSize.x = pbbg.rectTransform.rect.width;
|
||||
|
||||
//tempcounter += 0.0005f;
|
||||
|
||||
// resize the fill.
|
||||
RectTransform temp = fill.rectTransform;
|
||||
temp.sizeDelta = new Vector2 (barSize.x * barDisplay, barSize.y);
|
||||
RectTransform temp = pbf.rectTransform;
|
||||
//temp.sizeDelta = new Vector2 (-barSize.x + barSize.x * tempcounter, 0);
|
||||
temp.sizeDelta = new Vector2 (-barSize.x + (barSize.x * barDisplay), 0);
|
||||
temp.anchoredPosition = new Vector2 (temp.rect.width * 0.5f - (barSize.x * 0.5f),0);
|
||||
}
|
||||
|
||||
// Use this for the progress bar you're testing with.
|
||||
public void updateMyGoalProgressBar()
|
||||
{
|
||||
//Debug.Log (pbbg.rectTransform.rect.width + " " + pbbg.rectTransform.rect.height);
|
||||
barSize.x = mgpbbg.rectTransform.rect.width;
|
||||
|
||||
//tempcounter += 0.0005f;
|
||||
|
||||
// resize the fill.
|
||||
RectTransform temp = mgpbf.rectTransform;
|
||||
//temp.sizeDelta = new Vector2 (-barSize.x + barSize.x * tempcounter, 0);
|
||||
temp.sizeDelta = new Vector2 (-barSize.x + (barSize.x * barDisplay), 0);
|
||||
temp.anchoredPosition = new Vector2 (temp.rect.width * 0.5f - (barSize.x * 0.5f),0);
|
||||
}
|
||||
|
||||
// Call this to update the monster's progress bar.
|
||||
public void updateMonsterProgressBar()
|
||||
{
|
||||
float fractionused = (float)(timeUsed) / (float)(secondsperday);
|
||||
//Debug.Log (dayleft);
|
||||
|
||||
barSize.x = mpbbg.rectTransform.rect.width;
|
||||
|
||||
//tempcounter += 0.0005f;
|
||||
|
||||
// resize the fill.
|
||||
RectTransform temp = mpbf.rectTransform;
|
||||
//temp.sizeDelta = new Vector2 (-barSize.x + barSize.x * tempcounter, 0);
|
||||
temp.sizeDelta = new Vector2 (-barSize.x + (barSize.x * fractionused), 0);
|
||||
temp.anchoredPosition = new Vector2 (temp.rect.width * 0.5f - (barSize.x * 0.5f),0);
|
||||
}
|
||||
|
||||
// Calculates the time remaining for the day.
|
||||
// Will likely make a separate function for smaller timed goals if we have time.
|
||||
public void updateTimeRemaining()
|
||||
{
|
||||
timeUsed = ((System.DateTime.Now.Hour * 60 * 60) + (System.DateTime.Now.Minute * 60) + System.DateTime.Now.Second);
|
||||
|
||||
timeRemaining = secondsperday - timeUsed;
|
||||
}
|
||||
|
||||
// Format the time remaining variable to a proper string.
|
||||
public string formatTimeRemaining()
|
||||
{
|
||||
string output = "Time remaining: ";
|
||||
|
||||
output += "" + (timeRemaining / 3600);
|
||||
output += ":" + (timeRemaining % 3600 / 60);
|
||||
output += ":" + (timeRemaining % 60);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Shell function for now to update rival text.
|
||||
// You'll wanna call this with startcoroutine().
|
||||
public IEnumerator updateRival()
|
||||
{
|
||||
mp = new MochaParser ();
|
||||
yield return mp.MakeRequest ("http://corder.tech/mocha/random");
|
||||
rivalText.text = "You are being chased by " + mp.players [0].username;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
updateTimeRemaining ();
|
||||
updateProgressBar ();
|
||||
//needs current points counting toward this goal (daily?)
|
||||
//needs the total required points for this goal
|
||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
//barDisplay = Time.time*0.05f; //put actual progress here (current/total)
|
||||
|
||||
updateMyGoalProgressBar ();
|
||||
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
updateMonsterProgressBar ();
|
||||
remainingText.text = formatTimeRemaining ();
|
||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||
}
|
||||
|
||||
//userSteps = (int)(Time.time);
|
||||
//barDisplay = Time.time*0.05f;
|
||||
barDisplay = (float)userSteps/(float)stepsGoal;
|
||||
|
||||
//failed to complete goal
|
||||
if(currentDayStr != goalDayStr)
|
||||
//check if the current date matches the goal date
|
||||
if(prefKey == "daily" && currentDayStr == goalDayStr)
|
||||
{
|
||||
Debug.Log(currentDayStr);
|
||||
Debug.Log(goalDayStr);
|
||||
|
||||
Debug.Log("DAY HAS PASSED!!");
|
||||
|
||||
//make it so user dismisses the goal instead!
|
||||
//Destroy(this);
|
||||
//destroy the goal and set a new one?
|
||||
Debug.Log("current: " + currentDayStr);
|
||||
Debug.Log("goal: " + goalDayStr);
|
||||
Debug.Log(prefKey + "...DAY HAS PASSED!! SETTING GOAL TO NEXT DAY!!");
|
||||
PlayerPrefs.SetString("goalDate",
|
||||
System.DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"));
|
||||
goalDayStr = PlayerPrefs.GetString("goalDate");
|
||||
Debug.Log("new goal: " + goalDayStr);
|
||||
|
||||
//reset steps...
|
||||
userSteps = 0;
|
||||
PlayerPrefs.SetInt("currentSteps", userSteps);
|
||||
}
|
||||
//goal complete
|
||||
if(barDisplay >= 1.0f)
|
||||
|
@ -189,24 +260,12 @@ namespace PedometerU.Tests {
|
|||
PlayerPrefs.SetInt("totalPoints", savedPoints);
|
||||
pointsText.text = "Points: " + PlayerPrefs.GetInt("totalPoints").ToString ();
|
||||
|
||||
//Random item
|
||||
StringBuilder invList = new StringBuilder ();
|
||||
invList.Append(PlayerPrefs.GetString ("inventory"));
|
||||
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
|
||||
PlayerPrefs.SetString ("inventory", invList.ToString());
|
||||
}
|
||||
|
||||
//only applies if "daily" goal
|
||||
if(prefKey == "daily")
|
||||
{
|
||||
if(checkNewDay(prefKey))
|
||||
{
|
||||
Debug.Log("You failed your goal"); //not true if progress is actually complete!
|
||||
goalDayStr = currentDayStr;
|
||||
savePersistantGoalDate("daily");
|
||||
}
|
||||
//Random item
|
||||
StringBuilder invList = new StringBuilder ();
|
||||
invList.Append(PlayerPrefs.GetString ("inventory"));
|
||||
invList.Append(items[(int)Math.Round(UnityEngine.Random.value*6.0f)]).Append(" ");
|
||||
PlayerPrefs.SetString ("inventory", invList.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
10
MoCha/Assets/SimpleAndroidNotifications.meta
Normal file
10
MoCha/Assets/SimpleAndroidNotifications.meta
Normal file
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2df7842d377a9a84abfb17bc840cbab4
|
||||
folderAsset: yes
|
||||
timeCreated: 1525117456
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1568
MoCha/Assets/SimpleAndroidNotifications/DemoScene.unity
Normal file
1568
MoCha/Assets/SimpleAndroidNotifications/DemoScene.unity
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04bafa369dbac00478feecb96bf71f90
|
||||
timeCreated: 1504018996
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
MoCha/Assets/SimpleAndroidNotifications/Manual.pdf
Normal file
BIN
MoCha/Assets/SimpleAndroidNotifications/Manual.pdf
Normal file
Binary file not shown.
8
MoCha/Assets/SimpleAndroidNotifications/Manual.pdf.meta
Normal file
8
MoCha/Assets/SimpleAndroidNotifications/Manual.pdf.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 25883581d81d38b44b43224baa0c1bbe
|
||||
timeCreated: 1473442595
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.SimpleAndroidNotifications
|
||||
{
|
||||
public class NotificationExample : MonoBehaviour
|
||||
{
|
||||
public void Rate()
|
||||
{
|
||||
Application.OpenURL("http://u3d.as/y6r");
|
||||
}
|
||||
|
||||
public void OpenWiki()
|
||||
{
|
||||
Application.OpenURL("https://github.com/hippogamesunity/SimpleAndroidNotificationsPublic/wiki");
|
||||
}
|
||||
|
||||
public void ScheduleSimple()
|
||||
{
|
||||
NotificationManager.Send(TimeSpan.FromSeconds(5), "Simple notification", "Customize icon and color", new Color(1, 0.3f, 0.15f));
|
||||
}
|
||||
|
||||
public void ScheduleNormal()
|
||||
{
|
||||
NotificationManager.SendWithAppIcon(TimeSpan.FromSeconds(5), "Notification", "Notification with app icon", new Color(0, 0.6f, 1), NotificationIcon.Message);
|
||||
}
|
||||
|
||||
public void ScheduleCustom()
|
||||
{
|
||||
var notificationParams = new NotificationParams
|
||||
{
|
||||
Id = UnityEngine.Random.Range(0, int.MaxValue),
|
||||
Delay = TimeSpan.FromSeconds(5),
|
||||
Title = "Custom notification",
|
||||
Message = "Message",
|
||||
Ticker = "Ticker",
|
||||
Sound = true,
|
||||
Vibrate = true,
|
||||
Light = true,
|
||||
SmallIcon = NotificationIcon.Heart,
|
||||
SmallIconColor = new Color(0, 0.5f, 0),
|
||||
LargeIcon = "app_icon"
|
||||
};
|
||||
|
||||
NotificationManager.SendCustom(notificationParams);
|
||||
}
|
||||
|
||||
public void CancelAll()
|
||||
{
|
||||
NotificationManager.CancelAll();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3a71b5771fef6424bb435eb90ac4c555
|
||||
timeCreated: 1470125386
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
MoCha/Assets/SimpleAndroidNotifications/NotificationIcon.cs
Normal file
12
MoCha/Assets/SimpleAndroidNotifications/NotificationIcon.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace Assets.SimpleAndroidNotifications
|
||||
{
|
||||
public enum NotificationIcon
|
||||
{
|
||||
Bell,
|
||||
Clock,
|
||||
Event,
|
||||
Heart,
|
||||
Message,
|
||||
Star
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 243b640bb54d927499ad71bfe4b8137e
|
||||
timeCreated: 1473424878
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
123
MoCha/Assets/SimpleAndroidNotifications/NotificationManager.cs
Normal file
123
MoCha/Assets/SimpleAndroidNotifications/NotificationManager.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
|
||||
using System.Linq;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Assets.SimpleAndroidNotifications
|
||||
{
|
||||
public static class NotificationManager
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
|
||||
private const string FullClassName = "com.hippogames.simpleandroidnotifications.Controller";
|
||||
private const string MainActivityClassName = "com.unity3d.player.UnityPlayerActivity";
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Schedule simple notification without app icon.
|
||||
/// </summary>
|
||||
/// <param name="smallIcon">List of build-in small icons: notification_icon_bell (default), notification_icon_clock, notification_icon_heart, notification_icon_message, notification_icon_nut, notification_icon_star, notification_icon_warning.</param>
|
||||
public static int Send(TimeSpan delay, string title, string message, Color smallIconColor, NotificationIcon smallIcon = 0)
|
||||
{
|
||||
return SendCustom(new NotificationParams
|
||||
{
|
||||
Id = UnityEngine.Random.Range(0, int.MaxValue),
|
||||
Delay = delay,
|
||||
Title = title,
|
||||
Message = message,
|
||||
Ticker = message,
|
||||
Sound = true,
|
||||
Vibrate = true,
|
||||
Light = true,
|
||||
SmallIcon = smallIcon,
|
||||
SmallIconColor = smallIconColor,
|
||||
LargeIcon = ""
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule notification with app icon.
|
||||
/// </summary>
|
||||
/// <param name="smallIcon">List of build-in small icons: notification_icon_bell (default), notification_icon_clock, notification_icon_heart, notification_icon_message, notification_icon_nut, notification_icon_star, notification_icon_warning.</param>
|
||||
public static int SendWithAppIcon(TimeSpan delay, string title, string message, Color smallIconColor, NotificationIcon smallIcon = 0)
|
||||
{
|
||||
return SendCustom(new NotificationParams
|
||||
{
|
||||
Id = UnityEngine.Random.Range(0, int.MaxValue),
|
||||
Delay = delay,
|
||||
Title = title,
|
||||
Message = message,
|
||||
Ticker = message,
|
||||
Sound = true,
|
||||
Vibrate = true,
|
||||
Light = true,
|
||||
SmallIcon = smallIcon,
|
||||
SmallIconColor = smallIconColor,
|
||||
LargeIcon = "app_icon"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedule customizable notification.
|
||||
/// </summary>
|
||||
public static int SendCustom(NotificationParams notificationParams)
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
|
||||
var p = notificationParams;
|
||||
var delay = (long) p.Delay.TotalMilliseconds;
|
||||
|
||||
new AndroidJavaClass(FullClassName).CallStatic("SetNotification", p.Id, delay, p.Title, p.Message, p.Ticker,
|
||||
p.Sound ? 1 : 0, p.Vibrate ? 1 : 0, p.Light ? 1 : 0, p.LargeIcon, GetSmallIconName(p.SmallIcon), ColotToInt(p.SmallIconColor), MainActivityClassName);
|
||||
|
||||
#else
|
||||
|
||||
Debug.LogWarning("Simple Android Notifications are not supported for current platform. Build and play this scene on android device!");
|
||||
|
||||
#endif
|
||||
|
||||
return notificationParams.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel notification by id.
|
||||
/// </summary>
|
||||
public static void Cancel(int id)
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
|
||||
new AndroidJavaClass(FullClassName).CallStatic("CancelScheduledNotification", id);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel all notifications.
|
||||
/// </summary>
|
||||
public static void CancelAll()
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
|
||||
new AndroidJavaClass(FullClassName).CallStatic("CancelAllScheduledNotifications");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
private static int ColotToInt(Color color)
|
||||
{
|
||||
var smallIconColor = (Color32) color;
|
||||
|
||||
return smallIconColor.r * 65536 + smallIconColor.g * 256 + smallIconColor.b;
|
||||
}
|
||||
|
||||
private static string GetSmallIconName(NotificationIcon icon)
|
||||
{
|
||||
return "anp_" + icon.ToString().ToLower();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0126c966198c04149a015ab2e2993d7c
|
||||
timeCreated: 1470125384
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.SimpleAndroidNotifications
|
||||
{
|
||||
public class NotificationParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Use random id for each new notification.
|
||||
/// </summary>
|
||||
public int Id;
|
||||
public TimeSpan Delay;
|
||||
public string Title;
|
||||
public string Message;
|
||||
public string Ticker;
|
||||
public bool Sound = true;
|
||||
public bool Vibrate = true;
|
||||
public bool Light = true;
|
||||
public NotificationIcon SmallIcon;
|
||||
public Color SmallIconColor;
|
||||
/// <summary>
|
||||
/// Use "" for simple notification. Use "app_icon" to use the app icon. Use custom value but first place image to "simple-android-notifications.aar/res/". To modify "aar" file just rename it to "zip" and back.
|
||||
/// </summary>
|
||||
public string LargeIcon;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 21f9537b0dde1ff499b93870d79d2169
|
||||
timeCreated: 1470161197
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
MoCha/Assets/SimpleAndroidNotifications/Plugins.meta
Normal file
9
MoCha/Assets/SimpleAndroidNotifications/Plugins.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ae4658634a06794699458349d94b91a
|
||||
folderAsset: yes
|
||||
timeCreated: 1470052745
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 05659514faf5c00438b20237116fb96d
|
||||
folderAsset: yes
|
||||
timeCreated: 1470052745
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 452bdd37e0400c94491ff114e437eba0
|
||||
timeCreated: 1470202238
|
||||
licenseType: Store
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
MoCha/Assets/Sprites/Asset 1.png
Normal file
BIN
MoCha/Assets/Sprites/Asset 1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
107
MoCha/Assets/Sprites/Asset 1.png.meta
Normal file
107
MoCha/Assets/Sprites/Asset 1.png.meta
Normal file
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5e61f4351ff403445a1633bb46270048
|
||||
timeCreated: 1525112241
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
MoCha/Assets/Sprites/running_man.png
Normal file
BIN
MoCha/Assets/Sprites/running_man.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
107
MoCha/Assets/Sprites/running_man.png.meta
Normal file
107
MoCha/Assets/Sprites/running_man.png.meta
Normal file
|
@ -0,0 +1,107 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b868443409c4bd7488485b342bebc4d6
|
||||
timeCreated: 1525111249
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
- buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
m_EditorVersion: 2017.4.1f1
|
||||
m_EditorVersion: 2017.3.1f1
|
||||
|
|
Reference in a new issue