Merge remote-tracking branch 'origin/dev_cyp' into dev_nonearth

# Conflicts:
#	Assets/Resources/UI/language.json
This commit is contained in:
lishuo committed 2021-12-29 17:07:34 +08:00
commit eece0cffa5
401 files changed
+51471 -4540

No files matched your search

+24
View File
@@ -40,6 +40,8 @@ namespace Assets.Scripts.Apis
return Post<JsonResult<List<MapRecordRanking>>>("Map/GetCyclingRecordsById", id).data;
}
/// <summary>
/// 通过Id获取路书
@@ -51,6 +53,7 @@ namespace Assets.Scripts.Apis
return Get<JsonResult<MapRoute>>($"Map/GetMapRouteById?id={id}");
}
/// <summary>
///
/// </summary>
@@ -74,6 +77,16 @@ namespace Assets.Scripts.Apis
return GetAsync<JsonResult<List<MapRoute>>>(url);
}
public async Task<JsonResult<object>> CancelAreaFav(int areaId)
{
return await PostAsync<JsonResult<object>>("/MapRouteArea/CancelCollectArea", new { areaId });
}
public async Task<JsonResult<object>> AddAreaFav(int areaId)
{
return await PostAsync<JsonResult<object>>("/MapRouteArea/CollectArea",new { areaId});
}
/// <summary>
/// 从服务端获取Key
/// </summary>
@@ -197,5 +210,16 @@ namespace Assets.Scripts.Apis
var result = await GetAsync<JsonResult<List<MapMaxRanking>>>($"Map/GetMaxRanking");
return result;
}
public async Task<JsonResult<List<MapRouteAreaItem>>> GetRecommendAreaList()
{
var result = await GetAsync<JsonResult<List<MapRouteAreaItem>>>($"MapRouteArea/GetRecommendAreaList");
return result;
}
public async Task<JsonResult<List<MapRouteAreaItem>>> GetMemberMapRouteAreaList(int pageIndex, int pageSize)
{
var result = await GetAsync<JsonResult<List<MapRouteAreaItem>>>($"MapRouteArea/GetMemberMapRouteAreaList?pageIndex={pageIndex}&pageSize={pageSize}");
return result;
}
}
}
@@ -92,6 +92,8 @@ namespace Assets.Scripts.Apis.Models
///
/// </summary>
public int? ParentId { get; set; }
public bool IsFav { get; set; }
}
public class MapRouteAreaDetail
@@ -136,6 +138,7 @@ namespace Assets.Scripts.Apis.Models
///
/// </summary>
public DateTime UpdateTime { get; set; }
public bool IsFav { get; set; }
}
public class MapRouteAreaRouteList
@@ -49,5 +49,9 @@ namespace Assets.Scripts.Apis.Models
public double CurrentTotalClimb { get; set; }
public double CurrentTotalDistance { get; set; }
public double CurrentTotalKcal { get; set; }
public int ContinuesDay { get; set; }
public double ContinuesKcal { get; set; }
public double ContinuesKm { get; set; }
}
}
+46 -30
View File
@@ -189,40 +189,12 @@ namespace Assets.Scripts.Apis
public async Task<JsonResult<object>> OnWebWxLoginCheckUnionIdByCode(string code,string state)
{
var r = await GetAsync<JsonResult<object>>($"NoAuth/v1/OnWebWxLogin?code={code}&state={state}");
if (r.result)
{
var data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
return r;
}
else
{
var user = data.ToObject<UserResultModel>();
user.cookie = cookies[0].Value;
r.data = user;
}
}
return r;
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnWebWxLoginCheckUnionId(string unionId, string openId)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/OnWebWxLoginCheckUnionId", new { unionId, openId });
if (r.result)
{
var data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
return r;
}
else
{
var user = data.ToObject<UserResultModel>();
user.cookie = cookies[0].Value;
r.data = user;
}
}
return r;
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnWebWxLogin(string Phone, string Captcha,
string Password, string UnionId, string WxWebOpenId)
@@ -314,5 +286,49 @@ namespace Assets.Scripts.Apis
{
return await PostAsync<JsonResult<JObject>>("NoAuth/v1/ResetPassword", new {phone,captcha,newPwd });
}
public async Task<JsonResult<object>> OnAppleIdLoginCheck(string userId,string token)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnAppleIdLoginCheck", new { appleUserId = userId, token });
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnAppleIdLogin(string appleUserId, string token, string phone, string pwd, string Captcha)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnAppleIdLogin", new { appleUserId, token, phone, pwd, Captcha });
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnFacebookLoginCheck(string userId, string token)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnFacebookLoginCheck", new { faceBookUserId = userId, token });
return GetDataAfterSetCookie(r);
}
public async Task<JsonResult<object>> OnFacebookLogin(string faceBookUserId, string token, string phone, string pwd, string Captcha)
{
var r = await PostAsync<JsonResult<object>>("NoAuth/v1/OnFacebookLogin", new { faceBookUserId, token, phone, pwd, Captcha });
return GetDataAfterSetCookie(r);
}
private JsonResult<object> GetDataAfterSetCookie(JsonResult<object> r)
{
if (r.result)
{
var data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
return r;
}
else
{
var user = data.ToObject<UserResultModel>();
user.cookie = cookies[0].Value;
r.data = user;
}
}
return r;
}
}
}
+17 -7
View File
@@ -13,12 +13,13 @@ using System;
using System.Threading.Tasks;
using System.Timers;
using Newtonsoft.Json;
using Facebook.Unity;
public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.101:5085/";
public static string Host = "http://192.168.0.101:5083/";
public static string AppVersion = Application.version;
@@ -180,19 +181,28 @@ public static class App
{
InitLanguage();
#if !UNITY_EDITOR
//Host = "http://pf.juze.pro/";
Host = "http://pf.juze.pro/";
//Host = "http://192.168.0.101:5087/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
//线上
//Host = "https://wx.powerfun.com.cn/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
Host = "http://192.168.0.101:5085/";
UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
//本地
//Host = "http://192.168.0.101:5085/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
Debug.unityLogger.logEnabled = false;
#endif
if (!FB.IsInitialized)
{
FB.Init();
}
else
{
FB.ActivateApp();
}
var isRower = PlayerPrefs.GetString("IsRowerMode");
if (!string.IsNullOrEmpty(isRower))
{
+73 -12
View File
@@ -1,6 +1,7 @@
using Assets.Scripts;
using Assets.Scripts.Mobile.Interface;
using DG.Tweening;
using Facebook.Unity;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
@@ -20,13 +21,13 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
{
loginScrollView = transform.Find("Panel/LoginContainer/LoginScrollView").GetComponent<ScrollRect>();
thirdLoginPage = loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third");
UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer/BtnThirdLogin").gameObject,
UnityEngine.EventSystems.EventTriggerType.PointerClick,
(b)=> ShowThirdLoginPage());
UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third/BtnReturn").gameObject,
UnityEngine.EventSystems.EventTriggerType.PointerClick,
(b) => HideThirdLoginPage());
UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third/otherContainer/Wechat").gameObject,
//UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer/BtnThirdLogin").gameObject,
// UnityEngine.EventSystems.EventTriggerType.PointerClick,
// (b)=> ShowThirdLoginPage());
//UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer-third/BtnReturn").gameObject,
// UnityEngine.EventSystems.EventTriggerType.PointerClick,
// (b) => HideThirdLoginPage());
UIManager.AddEvent(loginScrollView.content.Find("FormContainer-Login/Mask/FormContainer/otherContainer/Wechat").gameObject,
UnityEngine.EventSystems.EventTriggerType.PointerClick,
(b) => goWxLogin());
}
@@ -41,17 +42,37 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
DateTime.Now.ToString("HH:mm");
weChat = App.weChatController;
weChat.Init(App.WxAppId);
#if UNITY_IOS
UIManager.AddEvent(transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Apple").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
#if UNITY_EDITOR
GetComponent<LoginController>()
.OnAppleIdLoginCheck("000515.7d1f47f5171b4d66a4bb4a4e7e2c6899.0830", "eyJraWQiOiJZdXlYb1kiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLlpoaVhpbmdQYWkuUG93ZXJGdW4iLCJleHAiOjE2NDAwNDk3NzEsImlhdCI6MTYzOTk2MzM3MSwic3ViIjoiMDAwNTE1LjdkMWY0N2Y1MTcxYjRkNjZhNGJiNGE0ZTdlMmM2ODk5LjA4MzAiLCJjX2hhc2giOiJhekhJdTZNVE1OVGs4Q3RxNndIeHlRIiwiYXV0aF90aW1lIjoxNjM5OTYzMzcxLCJub25jZV9zdXBwb3J0ZWQiOnRydWV9.WM23STabsJqSV1FjPvYRXo3kOB2Cfo7HsPDUuJx8UlqTUthbif1uvhEFpFMF8G5B5_yl3kkmaDtv0nQA25DkDiYowfPVV8gkLx2IMMOm6rVqV5E7kA6xNa64pwgIHDnTSjnn862_DEb4QVkAfi-rXsbkZ1q-EpH5MG-5GLR3Ktq_1n59kQcJrvuvUEpbv8IbSzRLh4VVZLY5rmaoddZ2kg5hw234cwGCmiMxHi55tVHAiGnqgq74IY7HXz3udwRGufaFXpkYbdBuL5-wqAp1SQlQhwpTzhZ5JKr2y4ukejYPFZzLfnkUX0xhLmH8uooKb-TjOa5qaFKGXT0hXh4NHw");
#else
App.weChatController.SignWithApple();
#endif
});
#else
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Apple").gameObject.SetActive(false);
#endif
UIManager.AddEvent(transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/otherContainer/Facebook").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
FB.LogOut();
FB.LogInWithReadPermissions(callback: onFaceBookResp);
});
//App.weChatController.Init(App.WxAppId);
//var s = App.weChatController.isApplicationAvilible("com.gugoumainapp","powerfun").ToString();
//Utils.showToast(null, SystemInfo.batteryLevel.ToString());
CheckUpdate();
}
private async void CheckUpdate()
{
#if UNITY_ANDROID
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
.gameObject.SetActive(true);
//transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
// .gameObject.SetActive(true);
#endif
var r = await ConfigHelper.userApi.GetVersions();
if (r.result)
@@ -68,9 +89,11 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
}
App.WorkoutsUrl = r.data.Value<JObject>("Apk").Value<string>("Url");
#elif UNITY_IOS
var sw = r.data.Value<string>("ThirdPartSwitch");
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
.gameObject.SetActive(sw.Equals("on") && App.weChatController.IsWeChatAppInstalled());
//var sw = r.data.Value<string>("ThirdPartSwitch");
//transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
// .gameObject.SetActive(sw.Equals("on") && App.weChatController.IsWeChatAppInstalled());
//transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
// .gameObject.SetActive(true);
var info = r.data.Value<JObject>("UnityIos");
if (Utils.isUpdate(App.AppVersion, info.Value<string>("Version")))
{
@@ -125,6 +148,32 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
}
#endif
}
/// <summary>
/// FaceBook登录返回
/// </summary>
/// <param name="res"></param>
private void onFaceBookResp(ILoginResult res)
{
Debug.Log(res.ToString());
if (string.IsNullOrEmpty(res.Error))
{
if (res.Cancelled)
{
Utils.showToast(null, App.GetLocalString("User deauthorisation"));
}
else
{
GetComponent<LoginController>()
.OnFacebookLoginCheck(res.ResultDictionary["user_id"].ToString(), res.ResultDictionary["access_token"].ToString());
Debug.Log("用戶Id" + res.ResultDictionary["user_id"]);
}
}
else
{
Utils.showToast(null, res.Error);
}
}
/// <summary>
/// 从ios或者安卓接收code,在c#里不建议调用
/// </summary>
@@ -140,4 +189,16 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
Utils.showToast(null, res.Replace("false;", ""));
}
}
public void OnAppleResp(string res)
{
#if UNITY_IOS
var sp = res.Replace("true;", "").Split(',');
if (sp.Length == 2)
{
GetComponent<LoginController>().OnAppleIdLoginCheck(sp[0],sp[1]);
}
//Utils.showToast(null, "苹果返回"+res);
#endif
}
}
+22 -5
View File
@@ -30,6 +30,12 @@ public class WeChatController
[DllImport("__Internal")]
private static extern void ShareImgToWX(int scene, byte[] msgByteArrayData, int arrayLength);
[DllImport("__Internal")]
private static extern void ShareUrlToWX(int scene, string url, string title, string description);
[DllImport("__Internal")]
private static extern void authorizationAppleID();
#endif
#endregion
/// <summary>
@@ -70,10 +76,17 @@ public class WeChatController
#endif
}
public void SignWithApple()
{
#if UNITY_IOS
authorizationAppleID();
#endif
}
/// <summary>
/// 判断是否是否安装了微信
/// </summary>
/// <returns></returns>
/// 判断是否是否安装了微信
/// </summary>
/// <returns></returns>
public bool IsWeChatAppInstalled()
{
#if UNITY_ANDROID
@@ -107,9 +120,13 @@ public class WeChatController
/// <param name="url">网页链接</param>
/// <param name="title">标题</param>
/// <param name="description">描述</param>
public void ShareWebpageToWX(int scene, string url, string title, string description)
public void ShareWebpageToWX(int scene, string url, string title, string description,byte[] image)
{
mainActivityClass.CallStatic("ShareWebpageToWX", scene, url, title, description);
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareWebpageToWX", scene, url, title, description, image);
#else
ShareUrlToWX(scene, url, title, description);
#endif
}
/// <summary>
+133 -32
View File
@@ -150,7 +150,7 @@ public class LoginController : BaseScene
var content = signScrollView.transform.Find("Viewport").Find("Content");
signPage1 = content.Find("FirstPage");
UIManager.AddEvent(signPage1.Find("next").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goRegNext());
EventTriggerType.PointerClick, (b) => goRegNext(signType));
UIManager.AddEvent(signPage1.Find("BtnModiPass").GetComponent<Button>().gameObject,
EventTriggerType.PointerClick, (b) => goResetPassword());
//signPage1.Find("next").GetComponent<Button>().onClick.AddListener(() => { goRegNext(); });
@@ -405,16 +405,10 @@ public class LoginController : BaseScene
{
if (pageNums == 5)
{
#if UNITY_ANDROID || UNITY_IOS
MobileAni(false);
#endif
StartScrollPanel(3);
}
else if (pageNums == 4)
{
#if UNITY_ANDROID || UNITY_IOS
MobileAni(false);
#endif
StartScrollPanel(2);
}
else
@@ -507,6 +501,67 @@ public class LoginController : BaseScene
transform.Find("Panel").Find("Version").GetComponent<Text>().text = $"V{App.AppVersion}";
#endif
}
private string fbUserId = "";
private string fbToken = "";
public async void OnFacebookLoginCheck(string userId, string token)
{
fbUserId = userId;
fbToken = token;
signType = 3;
var res = await ConfigHelper.userApi.OnFacebookLoginCheck(userId, token);
if (res.result) //判断是否成功登录
{
var data = JObject.FromObject(res.data);
if (data.ContainsKey("success") && data.Value<string>("success") == "False")
{
goSign();
}
else
{
RefreshWx3(data.ToObject<UserResultModel>(), 1);
wxLogin3.gameObject.SetActive(true);
signContainer.gameObject.SetActive(false);
pageNums = 3;
StartScrollPanel(2);
}
}
else
{
Utils.showToast(null, res.errMsg);
}
}
private string appleUserId = "";
private string appleToken = "";
private int signType { get; set; }
public async void OnAppleIdLoginCheck(string userId,string token)
{
appleUserId = userId;
appleToken = token;
signType = 2;
var res = await ConfigHelper.userApi.OnAppleIdLoginCheck(userId, token);
if (res.result) //判断是否成功登录
{
var data = JObject.FromObject(res.data);
if (data.ContainsKey("success") && data.Value<string>("success") == "False")
{
goSign();
}
else
{
RefreshWx3(data.ToObject<UserResultModel>(), 1);
wxLogin3.gameObject.SetActive(true);
signContainer.gameObject.SetActive(false);
pageNums = 3;
StartScrollPanel(2);
}
}
else
{
Utils.showToast(null, res.errMsg);
}
}
public void Test(string key)
{
@@ -514,8 +569,6 @@ public class LoginController : BaseScene
}
async void Init()
{
Debug.Log(535);
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
userInfos = UIManager.Instance.userInfos;
App.DefaultRotateTexture = Utils.ReadTextureFromPlayerPrefs("rotateImage");
@@ -697,6 +750,7 @@ public class LoginController : BaseScene
JObject data = JObject.FromObject(r.data);
if (data.Value<string>("success") != null && data.Value<string>("success") == "False")
{
signType = 1;
wxInfoJson = data;
wxLogin2.gameObject.SetActive(true);
Utils.DisplayImage(wxLogin2.Find("Avatar").GetComponent<RawImage>(),
@@ -720,7 +774,6 @@ public class LoginController : BaseScene
//wxLogin3.Find("NickName").GetComponent<Text>().text = wxInfoJson.Value<string>("nickname");
signContainer.gameObject.SetActive(false);
pageNums = 3;
MobileAni(true);
//this.goSign();
StartScrollPanel(2);
}
@@ -759,7 +812,7 @@ public class LoginController : BaseScene
//Timer t = new Ti
if (r.result)
{
if (pageNums == 5)
if (isThird())
{
if (r.data.Value<bool>("isExist"))
{
@@ -820,7 +873,7 @@ public class LoginController : BaseScene
signForm.cpassword.text = "";
StartScrollSign(0);
}
//0-普通 1-微信
//0-普通 1-微信 2-苹果 3-facebook
private async void goRegNext(int signType = 0)
{
var Email = signForm.email;
@@ -851,6 +904,14 @@ public class LoginController : BaseScene
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
}
else if (signType == 2)
{
r = await ConfigHelper.userApi.OnAppleIdLogin(appleUserId, appleToken, Email.text, Password.text, Captcha.text);
}
else
{
r = await ConfigHelper.userApi.OnFacebookLogin(fbUserId, fbToken, Email.text, Password.text, Captcha.text);
}
if (r != null && r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
@@ -870,21 +931,36 @@ public class LoginController : BaseScene
{
var Email = signForm.email;
var Captcha = signForm.captcha;
var r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
JsonResult<object> r = null;
if (signType == 2)
{
//苹果登录
r = await ConfigHelper.userApi.OnAppleIdLogin(appleUserId, appleToken, Email.text, "", Captcha.text);
}
else if (signType == 3)
{
r = await ConfigHelper.userApi.OnFacebookLogin(fbUserId, fbToken, Email.text, "", Captcha.text);
}
else
{
r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
Captcha.text,
"",
wxInfoJson.Value<string>("unionId"),
wxInfoJson.Value<string>("openId"));
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u, 1);
MobileAni(true);
StartScrollPanel(4);
}
else
if (r != null)
{
Utils.showToast(gameObject, r.errMsg);
if (r.result)
{
var u = JObject.FromObject(r.data).ToObject<UserResultModel>();
RefreshWx3(u, 1);
StartScrollPanel(4);
}
else
{
Utils.showToast(gameObject, r.errMsg);
}
}
}
/// <summary>
@@ -954,9 +1030,6 @@ public class LoginController : BaseScene
void goRegEnd()
{
if (!UpdateInfo()) return;
#if UNITY_ANDROID || UNITY_IOS
MobileAni(true);
#endif
if (pageNums == 5)
{
this.StartScrollPanel(4);
@@ -1041,9 +1114,9 @@ public class LoginController : BaseScene
/// </summary>
private void goLoginReturn2()
{
#if UNITY_ANDROID || UNITY_IOS
MobileAni(true);
#endif
//#if UNITY_ANDROID || UNITY_IOS
// MobileAni(true);
//#endif
if (wxLogin2.gameObject.activeSelf) wxLogin2.gameObject.SetActive(false);
//if (wxLogin3.gameObject.activeSelf) wxLogin3.gameObject.SetActive(false);
pageNums = 4;
@@ -1053,7 +1126,7 @@ public class LoginController : BaseScene
wxReturnLogin();
}
#else
transform.GetComponent<LoginControllerMobile>().HideThirdLoginPage();
//transform.GetComponent<LoginControllerMobile>().HideThirdLoginPage();
#endif
Canvas.ForceUpdateCanvases();
this.StartScrollPanel(1);
@@ -1082,6 +1155,11 @@ public class LoginController : BaseScene
LoginBg.localPosition = Vector3.zero;
LoginBg.GetComponent<RectTransform>().sizeDelta = new Vector2(360, 573);
#endif
imagedf.GetComponent<Image>().color = new Color(255, 255, 255, 0);
imagexf.GetComponent<Image>().color = new Color(255, 255, 255, 0);
LoginBg.GetComponent<RectTransform>().sizeDelta = new Vector2(354, 370);
LoginBg.GetComponent<RectTransform>().localPosition = new Vector2(LoginBg.GetComponent<RectTransform>().localPosition.x, 0);
var scrollValue = 1f / (pageNums - 1);
var value = 1 * scrollValue;
scrollPanel.horizontalNormalizedPosition = value;
@@ -1172,6 +1250,10 @@ public class LoginController : BaseScene
//signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
//signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { ; });
}
bool isThird()
{
return signType > 0;
}
/// <summary>
///
/// </summary>
@@ -1179,9 +1261,6 @@ public class LoginController : BaseScene
/// <param name="type">0 注册 1 忘记密码</param>
void goSign(bool isAccount = true, int type = 0)
{
#if UNITY_ANDROID || UNITY_IOS
MobileAni(false);
#endif
if (!isAccount)
{
pageNums = 5;
@@ -1201,6 +1280,10 @@ public class LoginController : BaseScene
if (type == 0)
{
pageNums = 4;
if (signType < 2)
{
signType = 0;
}
signContainer.Find("signText").GetComponent<Text>().text = App.GetLocalString("SIGN UP");
wxLogin2.gameObject.SetActive(false);
signPage1.Find("next").gameObject.SetActive(true);
@@ -1401,7 +1484,22 @@ public class LoginController : BaseScene
}
//float adjTime = 0;
//bool startJs = false;
#region 主页面滑动逻辑
#region 主页面滑动逻辑
private void handleAnimate(int index)
{
if (pageNums == 3)
{
MobileAni(index == 0 || index == 2);
}
else if (pageNums == 4)
{
MobileAni(index == 0 || index == 3);
}
else if (pageNums == 5)
{
MobileAni(index == 0 || index == 2 || index == 4);
}
}
private int tmpImdex = 0;
private int scrollPanelIndex = 2;
//private float scrollValue = 0.5f;
@@ -1409,6 +1507,9 @@ public class LoginController : BaseScene
private void StartScrollPanel(int index)
{
if (startScrollPanel) return;
#if UNITY_ANDROID || UNITY_IOS
handleAnimate(index);
#endif
scrollPanelIndex = index;
startScrollPanel = true;
}
+75 -8
View File
@@ -22,6 +22,7 @@ public class MainController : BaseScene
protected override void Awake()
{
base.Awake();
Debug.Log("执行25");
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
Version.text = "V"+App.AppVersion;
DeviceCache.Init(PFConstants.DeviceCacheFolder);
@@ -63,7 +64,7 @@ public class MainController : BaseScene
FinishMessage(sender);
}
CanvasGroup[] msgs;
List<CanvasGroup> msgs;
Vector3 msgLocation;
int msgIndex = 0;
CanvasGroup rightMessage;
@@ -81,9 +82,10 @@ public class MainController : BaseScene
msg3.transform.localPosition = 1 * msgLocation;
msg3.transform.localScale = Vector3.one;
msg3.alpha = 0;
msgs = new CanvasGroup[] { msg, msg2, msg3 };
msgs = List<CanvasGroup> { msg, msg2, msg3 };
rightMessage = transform.Find("GameObject/MessageRight").GetComponent<CanvasGroup>();
#else
msgLocation = new Vector3(168, 37, 0);
var go = transform.Find("GameObject");
go.GetComponent<RectTransform>().anchorMin = Vector2.zero;
go.GetComponent<RectTransform>().anchorMax = Vector2.one;
@@ -96,7 +98,18 @@ public class MainController : BaseScene
rightMessage.transform.SetParent(go);
rightMessage.transform.localScale = Vector3.one;
rightMessage.transform.localPosition = new Vector3(-112, 164, 0);
rightMessage.transform.localPosition = 1 * msgLocation;
msgs = new List<CanvasGroup> { rightMessage };
for (int i = 0; i < 5; i++)
{
var tmpm = Instantiate<CanvasGroup>(rightMessage);
tmpm.transform.SetParent(rightMessage.transform.parent);
tmpm.transform.localPosition = 1 * msgLocation;
tmpm.transform.localScale = Vector3.one;
tmpm.alpha = 0;
msgs.Add(tmpm);
}
Debug.Log(rightMessage.GetComponent<RectTransform>().localPosition);
//rightMessage.transform.SetParent(transform.Find("GameObject"));
#endif
@@ -119,7 +132,7 @@ public class MainController : BaseScene
#else
if (App.currentPageIsHome)
{
DoMessageRight(e);
DoMessage6(e);
}
#endif
}
@@ -155,6 +168,38 @@ public class MainController : BaseScene
}
msgIndex++;
}
private void DoMessage6(LinkedMessageEvent e)
{
var selectIndex = msgIndex % 6;
var m = msgs[selectIndex];
if (msgIndex >= 6) //
{
//msgIndex = 0;
m.DOFade(0, 0.5f).onComplete = () =>
{
SetMessage(m, e);
m.transform.localPosition = 1 * msgLocation;
m.DOFade(1, 0.5f);
foreach (var item in msgs.Where((x, i) => i != selectIndex))
{
item.transform.DOLocalMoveY(item.transform.localPosition.y - 38, 0.5f);
}
};
}
else
{
Debug.Log(191);
SetMessage(m, e);
for (int i = 0; i < msgIndex; i++)
{
var rect = msgs[i].GetComponent<RectTransform>();
rect.DOLocalMoveY(rect.localPosition.y - 38, 0.5f);
}
m.DOFade(1, 0.5f);
}
msgIndex++;
}
void FinishMessage(object sender)
{
#if UNITY_STANDALONE_WIN
@@ -169,7 +214,7 @@ public class MainController : BaseScene
#else
if (!(bool)sender)
{
FinishMessageRight();
FinishMessage6();
}
#endif
}
@@ -177,9 +222,12 @@ public class MainController : BaseScene
{
#if UNITY_STANDALONE_WIN
msgIndex = 0;
foreach (var item in msgs)
if (msgs != null)
{
item.DOFade(0, 0.3f);
foreach (var item in msgs)
{
item.DOFade(0, 0.3f);
}
}
#endif
}
@@ -189,8 +237,27 @@ public class MainController : BaseScene
msgIndex = 0;
rightMessage.DOFade(0, 0.3f);
}
void FinishMessage6()
{
msgIndex = 0;
foreach (var m in msgs)
{
m.alpha = 0;
m.GetComponent<RectTransform>().localPosition = 1 * msgLocation;
}
}
private void SetMessage(CanvasGroup m,LinkedMessageEvent e)
{
m.GetComponent<Button>().onClick.RemoveAllListeners();
m.GetComponent<Button>().onClick.AddListener(()=>
{
if (e.routeId > 0)
{
App.RouteIdParam = e.routeId;
SceneManager.LoadScene("Ride");
}
//Debug.Log(e.routeId);
});
m.transform.Find("Avatar").GetComponent<RawImage>().texture = null;
Utils.DisplayHead(m.transform.Find("Avatar").GetComponent<RawImage>(), e.avatar);
m.transform.Find("Nickname").GetComponent<Text>().text = e.nickname;
@@ -384,7 +451,7 @@ public class MainController : BaseScene
{
foreach (var item in res.data)
{
EventQueueSystem.QueueEvent(new LinkedMessageEvent(item.Id, item.Message, item.WxHeadImg, item.NickName));
EventQueueSystem.QueueEvent(new LinkedMessageEvent(-1, item.Message, item.WxHeadImg, item.NickName));
}
}
}
@@ -237,7 +237,7 @@ namespace Assets.Scenes.Ride.Scripts
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname);
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname, null);
}
else
{
@@ -249,7 +249,7 @@ namespace Assets.Scenes.Ride.Scripts
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname);
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname,null);
}
else
{
@@ -93,7 +93,7 @@ namespace Assets.Scenes.Ride.Scripts
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname);
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname,null);
}
else
{
@@ -105,7 +105,7 @@ namespace Assets.Scenes.Ride.Scripts
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname);
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.NickName, "By " + App.CurrentUser.Nickname,null);
}
else
{
+12 -2
View File
@@ -34,13 +34,24 @@ namespace Assets.Scripts.UI.Control
protected void Awake()
{
#if !(UNITY_ANDROID || UNITY_IOS)
//pc版依然让tooltip变成下面的
var newtool = transform.Find("Tooltips").gameObject;
var newrect = newtool.GetComponent<RectTransform>();
newrect.anchorMin = new Vector2(0.5f, 1);
newrect.anchorMax = new Vector2(0.5f, 1);
newrect.pivot = new Vector2(0.5f, 1);
newrect.anchoredPosition = new Vector2(0, -50);
//newrect.transform.localPosition = newrect.GetTruePosition(new Vector2(0, -50));
// -16 -66 0 -50
#endif
outline = this.GetComponent<Outline>();
if (mType == Type.Border && outline == null)
{
outline = this.gameObject.AddComponent<Outline>();
outline.effectDistance = new Vector2(2, 2);
}
//设置光标
//cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
@@ -76,7 +87,6 @@ namespace Assets.Scripts.UI.Control
}
}
tooltips.SetActive(false);
mButton = this.GetComponent<Button>();
InitColor();
@@ -381,15 +381,15 @@ public class DeviceView : MonoBehaviour
break;
case SensorType.SpeedCadence:
case SensorType.Cadence:
return "Cadence Sensor";
return App.GetLocalString("Cadence Sensor");
case SensorType.HeartRate:
return "Heart Rate Monitor";
return App.GetLocalString("Heart Rate Monitor");
case SensorType.Power:
return "Power Meter";
return App.GetLocalString("Power Meter");
case SensorType.Speed:
return "Speed Meter";
return App.GetLocalString("Speed Meter");
case SensorType.Trainer:
return "Smart Trainer";
return App.GetLocalString("Smart Trainer");
case SensorType.Rower:
return "Rower Machine";
case SensorType.VirtualPower:
+22 -1
View File
@@ -118,8 +118,29 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
Utils.DisplayImageTempDict(transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage, this.caches);
Utils.DisplayImageTempDict(transform.Find("MapHBImg").GetComponent<RawImage>(), myMap.AltitudeGraph, this.caches);
SetActive4Button(false);
#if UNITY_ANDROID || UNITY_IOS
var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null;
transform.Find("BtnContinue").gameObject.SetActive(isRecent);
transform.Find("BtnReride").gameObject.SetActive(isRecent);
transform.Find("MapHBImg").gameObject.SetActive(!isRecent);
if (isRecent)
{
transform.Find("BtnContinue").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("BtnReride").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("BtnContinue").GetComponent<Button>().onClick.AddListener(() =>
{
if (myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null)
{
App.RouteIdParam = myMap.RecentRecord.RouteId;
App.routeResult = myMap.RecentRecord;
SceneManager.LoadScene("Ride");
}
});
transform.Find("BtnReride").GetComponent<Button>().onClick.AddListener(Ride);
}
#endif
}
private void Ride()
+266
View File
@@ -0,0 +1,266 @@
using Assets.Scripts;
using Assets.Scripts.UI.Control;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class NewMainNav : MonoBehaviour
{
public class CustomButton
{
public Sprite image;
public UnityAction action;
public CustomButton(Sprite image, UnityAction action)
{
this.image = image;
this.action = action;
}
}
private GameObject exit;
private GameObject home;
private GameObject back;
float delayTime = 0;
private List<string> typeArray = new List<string>()
{
"Back","Exit","Home","Device","Delay","Setting","Support","Avatar","Custom","Custom2"
};
private List<int> indexs = new List<int>();
private int? shrinkIndex = null;
private CustomButton custom = null,custom2 = null;
/// <summary>
///
/// </summary>
/// <param name="indexs">仅展开显示的按钮:1:"Exit",3:"Device",4:"Delay",5:"Setting",6:"Support",7:"Avatar"</param>
/// <param name="shrinkIndex">合上后仍显示的按钮:0:"Back",2:"Home",null:仅PF</param>
/// <param name="custom">自定义按钮 8:c1 9:c2</param>
public void SetButtonActive(List<int> indexs,int? shrinkIndex = null, CustomButton custom = null, CustomButton custom2 = null)
{
this.indexs = indexs;
this.shrinkIndex = shrinkIndex;
this.custom = custom;
this.custom2 = custom2;
if (custom != null)
{
transform.Find("Custom").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("Custom").GetComponent<Button>().onClick.AddListener(custom.action);
transform.Find("Custom").GetComponent<Image>().sprite = custom.image;
indexs.Add(8);
}
if (custom2 != null)
{
transform.Find("Custom2").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("Custom2").GetComponent<Button>().onClick.AddListener(custom2.action);
transform.Find("Custom2").GetComponent<Image>().sprite = custom2.image;
indexs.Add(9);
}
SetExpand(false);
}
/// <summary>
/// true:展开 false:关闭
/// </summary>
/// <param name="flag"></param>
public void SetExpand(bool flag)
{
List<string> types = new List<string>();
if (indexs != null)
{
types = typeArray.Where((x, i) => indexs.Contains(i)).ToList();
}
string shrinkName = null;
if (shrinkIndex.HasValue && (shrinkIndex == 0 || shrinkIndex == 2))
{
shrinkName = typeArray[shrinkIndex.Value];
}
foreach (Transform item in transform)
{
if (flag)
{
if (item.name == "Down")
{
item.gameObject.SetActive(true);
}
else if (item.name == "PF")
{
item.gameObject.SetActive(false);
}
else if (item.name == "Custom")
{
item.gameObject.SetActive(custom != null && types.Contains(item.name));
}
else if (item.name == "Custom2")
{
item.gameObject.SetActive(custom2 != null && types.Contains(item.name));
}
else
{
item.gameObject.SetActive(types.Contains(item.name));
}
}
else
{
item.gameObject.SetActive(item.name == "PF"|| item.name == shrinkName);
}
}
}
public void ShowButton(string v)
{
var i = typeArray.FindIndex((x)=>x == v);
if (i == -1 || i == 0 || i == 2)
{
return;
}
indexs.Add(i);
SetExpand(false);
}
public void HideButton(string v)
{
var i = typeArray.FindIndex((x) => x == v);
if (i == -1 || i == 0 || i == 2)
{
return;
}
Debug.Log(i);
indexs.RemoveAll(x => x == i);
SetExpand(false);
}
private void Awake()
{
Utils.DisplayHead(transform.Find("Avatar").GetComponent<Image>(), App.CurrentUser.WxHeadImg);
UIManager.AddEvent(transform.Find("Avatar").gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowUserInfoPanel();
});
UIManager.AddEvent(transform.Find("PF").gameObject, EventTriggerType.PointerClick, b =>
{
SetExpand(true);
});
UIManager.AddEvent(transform.Find("Down").gameObject, EventTriggerType.PointerClick, b =>
{
SetExpand(false);
});
//var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
//var rect = ((RectTransform)this.transform).rect;
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
//this.GetComponent<Image>().material = material;
var device = this.transform.Find("Device");
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
{
//Debug.Log("click device");
UIManager.ShowDevicePanel();
});
home = this.transform.Find("Home").gameObject;
UIManager.AddEvent(home, EventTriggerType.PointerClick, x =>
{
UIManager.ShowHomePanel();
});
exit = this.transform.Find("Exit").gameObject;
exit.SetActive(false);
back = transform.Find("Back").gameObject;
back.SetActive(false);
#if UNITY_ANDROID || UNITY_IOS
UIManager.AddEvent(transform.Find("Delay").gameObject, EventTriggerType.PointerClick, b =>
{
delayTime = 3;
transform.Find("Delay/Tooltips").gameObject.SetActive(true);
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
#endif
//transform.Find("Delay").GetComponent<PfUIButton>().showTooltip = true;
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
Application.Quit();
},2);
});
UIManager.AddEvent(back, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowPrePanel();
});
UIManager.AddEvent(transform.Find("Setting").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowSettingModal();
});
UIManager.AddEvent(transform.Find("Support").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowFeedBackModal();
});
}
public void ShowRowerTab()
{
if (transform.Find("Device"))
{
transform.Find("Device").gameObject.SetActive(false);
}
if (transform.Find("Exit"))
{
transform.Find("Exit").gameObject.SetActive(true);
}
if (transform.Find("Home"))
{
transform.Find("Home").gameObject.SetActive(false);
}
}
// Start is called before the first frame update
void Start()
{
}
bool isTouch = false;
float hideTime = 5;
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
{
Debug.Log(235);
isTouch = true;
GetComponent<CanvasGroup>().DOFade(1, 0.5f);
}
hideTime -= Time.deltaTime;
if (hideTime < 0)
{
if (!isTouch)
{
GetComponent<CanvasGroup>().DOFade(0.4f, 0.5f);
}
isTouch = false;
hideTime += 5;
}
Debug.Log(Input.touchCount);
if (delayTime < 0)
{
Debug.Log("小时");
delayTime = 0;
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = ()=>
{
transform.Find("Delay/Tooltips").gameObject.SetActive(false);
};
}
else if(delayTime > 0)
{
Debug.Log(delayTime);
delayTime -= Time.deltaTime;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fca4162bdac783449b37ea751c075353
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -19,9 +19,10 @@ public class NewRouteItemController : MonoBehaviour
{
}
public MapRouteAreaItem Area { get; private set; }
public void Initial(MapRouteAreaItem area, Dictionary<string, Texture> caches = null)
{
this.Area = area;
transform.Find("Panel/Text").GetComponent<Text>().text = area.Name;
GetComponent<Button>().onClick.RemoveAllListeners();
GetComponent<Button>().onClick.AddListener(() =>
@@ -70,6 +70,17 @@ public class BigMapController : PFUIPanel
begin = Resources.Load("UI/Prefab/BigMap/Begin");
StartCoroutine("Main");
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("Canvas/Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 2, 3, 4, 6, 7 }, 2,
custom: new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/搜索"), () =>
{
mapManager.Destroy();
UIManager.PopStack();
UIManager.ShowNewRouteOverviewPanel();
}));
newNav = nav;
#endif
}
IEnumerator Main()
@@ -70,6 +70,13 @@ public class EarthController : PFUIPanel
panel = rootPanel.Find("Panel").gameObject;
#if UNITY_ANDROID || UNITY_IOS
SetRounded(panel.transform, 20);
var nav = transform.Find("Canvas/Panel/Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 2, 3, 4, 6, 7 }, 2,
custom: new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/搜索"), () =>
{
UIManager.ShowNewRouteOverviewPanel();
}));
newNav = nav;
#else
SetRounded(panel.transform, 60);
#endif
@@ -35,8 +35,22 @@ public class HomeController : PFUIPanel
protected override void Start()
{
base.Start();
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 });
newNav = nav;
UIManager.AddEvent(transform.Find("TodayData/Avatar").gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowUserInfoPanel();
});
UIManager.AddEvent(transform.Find("TodayData/Datas/Distance").gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowResultListPanel();
});
#else
mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
mainNav.ShowExit();
#endif
var BtnContainer = transform.Find("MainFuncContainer");
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerClick, GoRide);
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerEnter, OnHover);
@@ -226,6 +240,19 @@ public class HomeController : PFUIPanel
DateTime.Compare(App.CurrentUser.LastUpdateFtpTime, App.CurrentUser.LastUpdateWeightTime)>0
? App.CurrentUser.LastUpdateFtpTime.ToString("dd.MM.yyyy")
: App.CurrentUser.LastUpdateWeightTime.ToString("dd.MM.yyyy");
//新版设计稿
var todayData = transform.Find("TodayData");
if (todayData)
{
Utils.DisplayHead(todayData.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
todayData.Find("Datas/Distance/Value").GetComponent<Text>().text = $"{summary.ContinuesDay}"+ (summary.ContinuesDay > 1 ? App.GetLocalString("DAYS") : App.GetLocalString("DAY"));
todayData.Find("Datas/Climb/Value").GetComponent<Text>().text = $"{summary.ContinuesKm.ToString("#0")}KM";//$"{double.Parse(summary.TotalClimb, CultureInfo.InvariantCulture).ToString("0")}M";
todayData.Find("Datas/Carlories/Value").GetComponent<Text>().text = $"{summary.ContinuesKcal.ToString("#0")}KCAL";
//todayData.Find("Datas/Distance/Rank").GetComponent<Text>().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0")}";
todayData.Find("Datas/Climb/Rank").GetComponent<Text>().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0")}";
todayData.Find("Datas/Carlories/Rank").GetComponent<Text>().text = summary.CurrentTotalKcal == 0 ? "——" : $"+{summary.CurrentTotalKcal.ToString("#0")}";
}
}
async void GetSummary()
{
@@ -44,6 +44,8 @@ public class MapListController : PFUIPanel
return content;
}
}
private bool isEnd = false;
private Transform topContainer;
void ResetPage()
@@ -82,10 +84,7 @@ public class MapListController : PFUIPanel
var mc = transform.Find("MC");
UIManager.AddEvent(transform.Find("SwitchMode/BtnFilter").gameObject, EventTriggerType.PointerClick, b =>
{
topContainer.DOLocalMoveX(App.topRectStartX.Value + topRect.rect.width, 0.3f);
mc.gameObject.SetActive(true);
mc.GetComponent<CanvasGroup>().alpha = 0;
mc.GetComponent<CanvasGroup>().DOFade(1, 0.3f);
OpenFilter();
});
UIManager.AddEvent(mc.gameObject, EventTriggerType.PointerClick, b =>
{
@@ -96,6 +95,14 @@ public class MapListController : PFUIPanel
};
});
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem-Mobile");
Debug.Log(98);
var nav = transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 0, 3, 4, 6, 7 }, 0,
new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/Mobile/map_筛选"), () =>
{
OpenFilter();
}));
newNav = nav;
#else
topContainer = transform.Find("Panel").Find("Top");
#endif
@@ -106,9 +113,10 @@ public class MapListController : PFUIPanel
{
Application.OpenURL("http://192.168.0.101:3081/Mine/Upload?token="+ App.CurrentUser.cookie);
});
#endif
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
#endif
sort = "Near";
sortDire = "asc";
//if (hardSelector != null)
@@ -278,6 +286,22 @@ public class MapListController : PFUIPanel
}
caches = new Dictionary<string, Texture>();
}
public void OpenFilter()
{
#if UNITY_ANDROID || UNITY_IOS
var topRect = transform.Find("Top").GetComponent<RectTransform>();
if (!App.topRectStartX.HasValue)
{
App.topRectStartX = topRect.localPosition.x;
}
topRect.DOLocalMoveX(App.topRectStartX.Value + topRect.rect.width, 0.3f);
var mc = transform.Find("MC");
mc.gameObject.SetActive(true);
mc.GetComponent<CanvasGroup>().alpha = 0;
mc.GetComponent<CanvasGroup>().DOFade(1, 0.3f);
#endif
topRect.Find("SearchInput").GetComponent<InputField>().OnPointerClick(new PointerEventData(EventSystem.current));
}
void onEndEdit()
{
var t = searchInput.GetComponent<InputField>().text;
@@ -369,7 +393,7 @@ public class MapListController : PFUIPanel
}
}
Dictionary<string, Texture> caches = null;
public Dictionary<string, Texture> caches = null;
void DisplayMaps(List<MapRoute> list)
{
if (map != null)
@@ -398,7 +422,7 @@ public class MapListController : PFUIPanel
#if !(UNITY_ANDROID || UNITY_IOS)
var routeTypeName = transform.Find("Panel/Top/RouteTypeName");
#else
var routeTypeName = transform.Find("Panel/RouteTypeName");
var routeTypeName = transform.Find("RouteTypeName");
#endif
routeTypeName.GetComponent<Text>().text = App.GetLocalString(App.CurrentRouteType);
if (searchInput != null)
@@ -452,7 +476,7 @@ public class MapListController : PFUIPanel
{
isMine = true;
}
else if (App.CurrentRouteType == "My Collection")
else if (App.CurrentRouteType == "My Collection" || topContainer.Find("FavContainer/Gou").gameObject.activeInHierarchy)
{
isFav = true;
}
@@ -510,6 +534,7 @@ public class MapListController : PFUIPanel
{
transform.Find("RawImage").GetComponent<RawImage>().texture = App.DefaultRotateTexture;
}
GetComponent<MapListExtraController>().HandleCollection();
#if UNITY_ANDROID || UNITY_IOS
ResetPage();
#endif
@@ -0,0 +1,109 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.Apis.Models;
using Assets.Scripts.UI.Prefab.MapList;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
/// <summary>
/// 处理一些额外需求
/// </summary>
public class MapListExtraController : PFUIPanel
{
private Transform typeSelector, p1, p2;
private float p1originx = 0, p2originx = 0;
private Transform tmpCollectItem;
protected override void Awake()
{
typeSelector = transform.Find("TypeSelector");
p1 = transform.Find("Panel/Panel");
p2 = transform.Find("Panel/Panel备用");
p1originx = p1.GetComponent<RectTransform>().localPosition.x;
p2originx = p2.GetComponent<RectTransform>().localPosition.x;
#if UNITY_ANDROID || UNITY_IOS
tmpCollectItem = Resources.Load<Transform>("UI/Prefab/NewRoute/Mobile/RouteItem");
#else
tmpCollectItem = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteItem");
#endif
UIManager.AddEvent(typeSelector.Find("Route").gameObject, EventTriggerType.PointerClick, b =>
{
typeSelector.Find("Route").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
typeSelector.Find("Collection").GetComponent<Text>().color = Utils.HexToColorHtml("#5c5c6e");
p1.DOLocalMoveX(p1originx, 0.5f);
p2.DOLocalMoveX(p2originx, 0.5f);
transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>().ShowButton("Custom");
});
UIManager.AddEvent(typeSelector.Find("Collection").gameObject, EventTriggerType.PointerClick, b =>
{
typeSelector.Find("Route").GetComponent<Text>().color = Utils.HexToColorHtml("#5c5c6e");
typeSelector.Find("Collection").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
p1.DOLocalMoveX(p1originx - 764f, 0.5f);
p2.DOLocalMoveX(p2originx - 764f, 0.5f);
transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>().HideButton("Custom");
});
}
protected override void Start()
{
}
void Update()
{
}
public override void Show()
{
base.Show();
}
private int pageIndex = 0;
public void HandleCollection()
{
if (App.CurrentRouteType == "My Collection")
{
typeSelector.gameObject.SetActive(true);
RefreshCollectList();
}
else
{
typeSelector.gameObject.SetActive(false);
}
p1.localPosition = new Vector3(p1originx, p1.localPosition.y, p1.localPosition.z);
p2.localPosition = new Vector3(p2originx, p2.localPosition.y, p2.localPosition.z);
typeSelector.Find("Route").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
typeSelector.Find("Collection").GetComponent<Text>().color = Utils.HexToColorHtml("#5c5c6e");
transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>().ShowButton("Custom");
}
private async void GetList()
{
var res = await ConfigHelper.mapApi.GetMemberMapRouteAreaList(pageIndex, 10);
if (res.result)
{
foreach (var area in res.data)
{
var item = Instantiate<Transform>(tmpCollectItem);
item.GetComponent<NewRouteItemController>().Initial(area, GetComponent<MapListController>().caches);
item.SetParent(p2.Find("Scroll View/Viewport/Content"));
item.localScale = Vector3.one;
}
}
}
private void RefreshCollectList()
{
p2.Find("Scroll View/Viewport/Content").DestroyChildren();
pageIndex = 0;
GetList();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a011dd1cd8044a418d1b92b2474ee7c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -15,10 +15,16 @@ public class NewRouteDetailController : PFUIPanel
Dictionary<string, Texture> caches;
GameObject map;
ScrollRect scroll;
Dictionary<bool, Sprite> FavDict;
List<int> routeIds { get; set; }
protected override void Awake()
{
FavDict = new Dictionary<bool, Sprite>()
{
{false,Resources.Load<Sprite>("Images/NewDesign/icon_heji_unlike") },
{true,Resources.Load<Sprite>("Images/NewDesign/icon_heji_like") },
};
caches = new Dictionary<string, Texture>();
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
@@ -50,7 +56,37 @@ public class NewRouteDetailController : PFUIPanel
}
void Start()
{
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 0, 3, 4, 6, 7 }, 0);
newNav = nav;
UIManager.AddEvent(transform.Find("Container/Left/Fav").gameObject, EventTriggerType.PointerClick, async b =>
{
Assets.Scripts.Apis.JsonResult<object> res = null;
var p = ((PointerEventData)b).pointerEnter;
var act = ((PointerEventData)b).pointerEnter.GetComponent<Image>().sprite.name == "icon_heji_like";
if (act)
{
res = await ConfigHelper.mapApi.CancelAreaFav(area.Id);
}
else
{
res = await ConfigHelper.mapApi.AddAreaFav(area.Id);
}
if (res.result)
{
p.GetComponent<Image>().sprite = FavDict[!act];
Utils.showToast(null, App.GetLocalString("Success"), type: 1);
}
else
{
Utils.showToast(null, res.errMsg);
}
});
#else
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
#endif
var rect = transform.GetComponent<RectTransform>();
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
@@ -109,16 +145,79 @@ public class NewRouteDetailController : PFUIPanel
.text = string.Empty;
transform.Find("Container/Left/Desc").GetComponent<Text>()
.text = string.Empty;
if (area.BannerImage != null)
if (area.CoverImage != null)
{
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.BannerImage, caches);
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.CoverImage, caches
, b =>
{
#if UNITY_EDITOR
var _t = new Texture2D(4, 4, TextureFormat.DXT5, false);
#else
#if UNITY_IOS
var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
Debug.Log("使用了壓縮");
#elif UNITY_ANDROID
var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
Debug.Log("使用了壓縮");
#else //pc
var _t = new Texture2D(4, 4, TextureFormat.DXT5,false);
#endif
#endif
_t.LoadImage(b);
//Graphics.CopyTexture(t, _t);
//Debug.Log($"{t.width},{t.height}");
left.Find("Thumbnail").GetComponent<RawImage>().texture =
ScaleTextureCutOut(_t, 0, _t.height / 2, _t.width / 3, _t.height / 3);
});
//Utils.DisplayImageTempDict(left.Find("Thumbnail").GetComponent<RawImage>(), area.CoverImage, caches);
}
Debug.Log(153 + area.IsFav.ToString());
left.Find("Name").GetComponent<Text>().text = area.Name;
GetData();
GetList();
}
Texture2D ScaleTextureCutOut(Texture2D originalTexture, float startX, float startY, float originalWidth, float originalHeight)
{
originalWidth = Mathf.Clamp(originalWidth, 0, Mathf.Max(originalTexture.width - startX, 0));
originalHeight = Mathf.Clamp(originalHeight, 0, Mathf.Max(originalTexture.height - startY, 0));
Texture2D newTexture = new Texture2D(Mathf.CeilToInt(originalWidth), Mathf.CeilToInt(originalHeight));
int maxX = originalTexture.width - 1;
int maxY = originalTexture.height - 1;
for (int y = 0; y < newTexture.height; y++)
{
for (int x = 0; x < newTexture.width; x++)
{
float targetX = x + startX;
float targetY = y + startY;
int x1 = Mathf.Min(maxX, Mathf.FloorToInt(targetX));
int y1 = Mathf.Min(maxY, Mathf.FloorToInt(targetY));
int x2 = Mathf.Min(maxX, x1 + 1);
int y2 = Mathf.Min(maxY, y1 + 1);
float u = targetX - x1;
float v = targetY - y1;
float w1 = (1 - u) * (1 - v);
float w2 = u * (1 - v);
float w3 = (1 - u) * v;
float w4 = u * v;
Color color1 = originalTexture.GetPixel(x1, y1);
Color color2 = originalTexture.GetPixel(x2, y1);
Color color3 = originalTexture.GetPixel(x1, y2);
Color color4 = originalTexture.GetPixel(x2, y2);
Color color = new Color(Mathf.Clamp01(color1.r * w1 + color2.r * w2 + color3.r * w3 + color4.r * w4),
Mathf.Clamp01(color1.g * w1 + color2.g * w2 + color3.g * w3 + color4.g * w4),
Mathf.Clamp01(color1.b * w1 + color2.b * w2 + color3.b * w3 + color4.b * w4),
Mathf.Clamp01(color1.a * w1 + color2.a * w2 + color3.a * w3 + color4.a * w4)
);
newTexture.SetPixel(x, y, color);
}
}
newTexture.anisoLevel = 2;
newTexture.Apply();
return newTexture;
}
private void OnEndDrag(BaseEventData arg0)
{
Debug.Log(scroll.verticalNormalizedPosition);
@@ -143,6 +242,7 @@ public class NewRouteDetailController : PFUIPanel
.text = $"{res.data.AverageGrade.ToString("#0.00")}%";
transform.Find("Container/Left/Desc").GetComponent<Text>()
.text = res.data.Description;
transform.Find("Container/Left/Fav").GetComponent<Image>().sprite = FavDict[res.data.IsFav];
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.Find("Container/Left/RideContainer").GetComponent<RectTransform>());
}
}
@@ -21,6 +21,20 @@ public class NewRouteOverviewController: PFUIPanel
{
caches = new Dictionary<string, Texture>();
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
scroll.onValueChanged.RemoveAllListeners();
scroll.onValueChanged.AddListener(p=>
{
var rect = transform.Find("Container").GetComponent<RectTransform>();
//Debug.Log($"{rect.offsetMin} {rect.offsetMax}");
if (p.y < 0.9)
{
DOTween.To(() => rect.offsetMax, x => rect.offsetMax = x, new Vector2(rect.offsetMax.x, -10), 0.5f);
}
else
{
DOTween.To(() => rect.offsetMax, x => rect.offsetMax = x, new Vector2(rect.offsetMax.x, -68), 0.5f);
}
});
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
}
@@ -50,6 +64,15 @@ public class NewRouteOverviewController: PFUIPanel
tmpGroup = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteGroup");
tmpItem = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteItem");
#else
var nav = transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 2, 3, 4, 6, 7 }, 2,
new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/map_mode"),()=>
{
UIManager.PopStack();
//UIManager.ShowBigMapPanel();
UIManager.ShowEarthPanel(App.latitude, App.longitude);
}));
newNav = nav;
var rect = transform.GetComponent<RectTransform>();
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
@@ -88,6 +111,10 @@ public class NewRouteOverviewController: PFUIPanel
{
ToList("All Route");
});
UIManager.AddEvent(transform.Find("Container/BtnSearch").gameObject, EventTriggerType.PointerClick, b =>
{
GoSearch();
});
BindHeadImage();
//banner暂时注释
//#if !(UNITY_ANDROID || UNITY_IOS)
@@ -180,15 +207,22 @@ public class NewRouteOverviewController: PFUIPanel
}
/// <summary>
/// 绑定头像
///
/// </summary>
void ToList(string type)
{
App.CurrentRouteType = type;// "";
UIManager.ShowMapListPanel();
}
void GoSearch()
{
App.CurrentRouteType = "All Route";// "";
UIManager.ShowMapListPanel(panel=>
{
panel.OpenFilter();
});
}
public override void Show()
{
base.Show();
+1 -1
View File
@@ -12,7 +12,7 @@ using Assets.Scripts;
//{
public class PFUIPanel : UIBehaviour
{
public NewMainNav newNav = null;
public void OpenURL(string url)
{
Application.OpenURL(url);
@@ -75,6 +75,14 @@ public class RaceHomeScript : RaceScript
btnGoList = rightContainer.Find("Container-2/BtnGoList");
#else
btnGoList = rightContainer.Find("BtnGoList");
var nav = transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 0, 3, 4, 6, 7 }, 0,
custom: new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/Race/back down"), () =>
{
//OpenFilter();
UIManager.ShowRaceListPanel();
}));
newNav = nav;
#endif
if (btnGoList != null)
{
@@ -245,6 +245,18 @@ public class RaceListScript : RaceScript
mc.gameObject.SetActive(false);
};
});
var nav = transform.Find("Tmp/MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 0, 3, 4, 6, 7 }, 0,
custom: new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/Mobile/map_筛选"), () =>
{
//OpenFilter();
conditions.DOLocalMoveX(App.topRectStartX.Value + topRect.rect.width, 0.3f);
mc.gameObject.SetActive(true);
mc.GetComponent<CanvasGroup>().alpha = 0;
mc.GetComponent<CanvasGroup>().DOFade(1, 0.3f);
}));
newNav = nav;
#else
#endif
}
@@ -178,6 +178,19 @@ public class RouteItem : MonoBehaviour
//btnDelete.gameObject.SetActive(false);
//btnDelete.GetComponent<Button>().onClick.AddListener(Delete);
#if UNITY_ANDROID || UNITY_IOS
UIManager.AddEvent(left.Find("Main/ShareContainer/Wx").gameObject, EventTriggerType.PointerClick, b =>
{
Debug.Log(App.CurrentUser.WebHost);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, $"http://{App.CurrentUser.WebHost}/RoutesRecords/" + result.RankingId, result.RouteName, "By " + App.CurrentUser.Nickname, null);
}
else
{
Utils.showToast(null, "未安装微信");
}
});
UIManager.AddEvent(btnDelete.gameObject, EventTriggerType.PointerClick, (b) => Detail());
#else
UIManager.AddEvent(btnDelete.gameObject, EventTriggerType.PointerClick, (b) => Delete());
+3 -2
View File
@@ -1,8 +1,9 @@
fileFormatVersion: 2
guid: d3d31d70cf492e34096ffdc82042d396
guid: 04feaefc7cdee4c13abcd553a1a6e3a9
folderAsset: yes
timeCreated: 1528368324
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -12,7 +12,7 @@ using System.Linq;
#endif
#endif
namespace Assets.Scripts.UI.UIEffect.Common
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Base class for effects that modify the generated Mesh.
@@ -27,10 +27,10 @@ namespace Assets.Scripts.UI.UIEffect.Common
#if TMP_PRESENT
static readonly List<Vector2> s_Uv0 = new List<Vector2> (4096);
static readonly List<Vector2> s_Uv1 = new List<Vector2> (4096);
#if UNITY_2017_1_OR_NEWER
#if UNITY_2017_1_OR_NEWER
static readonly List<Vector2> s_Uv2 = new List<Vector2> (4096);
static readonly List<Vector2> s_Uv3 = new List<Vector2> (4096);
#endif
#endif
static readonly List<Vector3> s_Vertices = new List<Vector3> (4096);
static readonly List<int> s_Indices = new List<int> (4096);
static readonly List<Vector3> s_Normals = new List<Vector3> (4096);
@@ -42,7 +42,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
static readonly List<UIVertex> s_UIVertices = new List<UIVertex> (4096);
static readonly List<BaseMeshEffect> s_TmpEffects = new List<BaseMeshEffect>(4);
#endif
static readonly Material[] s_EmptyMaterials = new Material[0];
static readonly Material [] s_EmptyMaterials = new Material [0];
//################################
@@ -51,12 +51,12 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// The Graphic attached to this GameObject.
/// </summary>
public Graphic graphic { get { Initialize(); return _graphic; } }
public Graphic graphic { get { Initialize (); return _graphic; } }
/// <summary>
/// The CanvasRenderer attached to this GameObject.
/// </summary>
public CanvasRenderer canvasRenderer { get { Initialize(); return _canvasRenderer; } }
public CanvasRenderer canvasRenderer { get { Initialize (); return _canvasRenderer; } }
#if TMP_PRESENT
/// <summary>
@@ -68,7 +68,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// The RectTransform attached to this GameObject.
/// </summary>
public RectTransform rectTransform { get { Initialize(); return _rectTransform; } }
public RectTransform rectTransform { get { Initialize (); return _rectTransform; } }
#if UNITY_5_6_OR_NEWER
/// <summary>
@@ -146,7 +146,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
#endif
if (graphic)
{
_materials[0] = graphic.material;
_materials [0] = graphic.material;
return _materials;
}
else
@@ -160,7 +160,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// Call used to modify mesh. (legacy)
/// </summary>
/// <param name="mesh">Mesh.</param>
public virtual void ModifyMesh(Mesh mesh)
public virtual void ModifyMesh (Mesh mesh)
{
}
@@ -168,14 +168,14 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// Call used to modify mesh.
/// </summary>
/// <param name="vh">VertexHelper.</param>
public virtual void ModifyMesh(VertexHelper vh)
public virtual void ModifyMesh (VertexHelper vh)
{
}
/// <summary>
/// Mark the vertices as dirty.
/// </summary>
public virtual void SetVerticesDirty()
public virtual void SetVerticesDirty ()
{
#if TMP_PRESENT
if (textMeshPro)
@@ -213,11 +213,11 @@ namespace Assets.Scripts.UI.UIEffect.Common
#endif
if (graphic)
{
graphic.SetVerticesDirty();
graphic.SetVerticesDirty ();
}
}
public void ShowTMProWarning(Shader shader, Shader mobileShader, Shader spriteShader, System.Action<Material> onCreatedMaterial)
public void ShowTMProWarning (Shader shader, Shader mobileShader, Shader spriteShader, System.Action<Material> onCreatedMaterial)
{
#if UNITY_EDITOR && TMP_PRESENT
if(!textMeshPro || !textMeshPro.fontSharedMaterial)
@@ -324,14 +324,14 @@ namespace Assets.Scripts.UI.UIEffect.Common
protected virtual bool isLegacyMeshModifier { get { return false; } }
protected virtual void Initialize()
protected virtual void Initialize ()
{
if (!_initialized)
{
_initialized = true;
_graphic = _graphic ?? GetComponent<Graphic>();
_canvasRenderer = _canvasRenderer ?? GetComponent<CanvasRenderer>();
_rectTransform = _rectTransform ?? GetComponent<RectTransform>();
_graphic = _graphic ?? GetComponent<Graphic> ();
_canvasRenderer = _canvasRenderer ?? GetComponent<CanvasRenderer> ();
_rectTransform = _rectTransform ?? GetComponent<RectTransform> ();
#if TMP_PRESENT
_textMeshPro = _textMeshPro ?? GetComponent<TMP_Text> ();
#endif
@@ -341,10 +341,10 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
protected override void OnEnable ()
{
_initialized = false;
SetVerticesDirty();
SetVerticesDirty ();
#if TMP_PRESENT
if (textMeshPro)
{
@@ -366,7 +366,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
var canvas = graphic.canvas;
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
{
Debug.LogWarningFormat(this, "Enable {1} of Canvas.additionalShaderChannels to use {0}.", GetType().Name, channels);
Debug.LogWarningFormat (this, "Enable {1} of Canvas.additionalShaderChannels to use {0}.", GetType ().Name, channels);
}
}
#endif
@@ -375,12 +375,12 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
protected override void OnDisable()
protected override void OnDisable ()
{
#if TMP_PRESENT
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove (OnTextChanged);
#endif
SetVerticesDirty();
SetVerticesDirty ();
#if UNITY_EDITOR && TMP_PRESENT
if (graphic && textMeshPro)
@@ -394,7 +394,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// LateUpdate is called every frame, if the Behaviour is enabled.
/// </summary>
protected virtual void LateUpdate()
protected virtual void LateUpdate ()
{
#if TMP_PRESENT
if (textMeshPro)
@@ -411,18 +411,18 @@ namespace Assets.Scripts.UI.UIEffect.Common
/// <summary>
/// Callback for when properties have been changed by animation.
/// </summary>
protected override void OnDidApplyAnimationProperties()
protected override void OnDidApplyAnimationProperties ()
{
SetVerticesDirty();
SetVerticesDirty ();
}
#if UNITY_EDITOR
/// <summary>
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
/// </summary>
protected override void OnValidate()
protected override void OnValidate ()
{
SetVerticesDirty();
SetVerticesDirty ();
}
#endif
@@ -434,7 +434,7 @@ namespace Assets.Scripts.UI.UIEffect.Common
CanvasRenderer _canvasRenderer;
RectTransform _rectTransform;
Graphic _graphic;
Material[] _materials = new Material[1];
Material [] _materials = new Material [1];
#if TMP_PRESENT
bool _isTextMeshProActive;
@@ -532,12 +532,12 @@ namespace Assets.Scripts.UI.UIEffect.Common
mesh.GetTangents (s_Tangents);
mesh.GetIndices (s_Indices, 0);
#if UNITY_2017_1_OR_NEWER
#if UNITY_2017_1_OR_NEWER
mesh.GetUVs (2, s_Uv2);
mesh.GetUVs (3, s_Uv3);
bool useUv2 = 0 < s_Uv2.Count;
bool useUv3 = 0 < s_Uv3.Count;
#endif
#endif
s_UIVertices.Clear();
UIVertex v = default(UIVertex);
@@ -547,12 +547,12 @@ namespace Assets.Scripts.UI.UIEffect.Common
v.color = s_Colors[i];
v.uv0 = s_Uv0[i];
v.uv1 = s_Uv1[i];
#if UNITY_2017_1_OR_NEWER
#if UNITY_2017_1_OR_NEWER
if (useUv2 && i < s_Uv2.Count)
v.uv2 = s_Uv2[i];
if (useUv3 && i < s_Uv3.Count)
v.uv3 = s_Uv3[i];
#endif
#endif
v.normal = s_Normals[i];
v.tangent = s_Tangents[i];
@@ -562,4 +562,4 @@ namespace Assets.Scripts.UI.UIEffect.Common
}
#endif
}
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c52a957894a7bbf418d6b190bd7816a3
guid: 229ee7044e2514b0e9bd9fd40a2baa3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -0,0 +1,13 @@
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Blur effect mode.
/// </summary>
public enum BlurMode
{
None = 0,
FastBlur = 1,
MediumBlur = 2,
DetailBlur = 3,
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5645838b01af8764d8f381f04b62b9a2
timeCreated: 1528296875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Color effect mode.
/// </summary>
public enum ColorMode
{
Multiply = 0,
Fill = 1,
Add = 2,
Subtract = 3,
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e6ba1e487e0a19644afde2bd5531bd04
timeCreated: 1528296875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,112 @@
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Area for effect.
/// </summary>
public enum EffectArea
{
RectTransform,
Fit,
Character,
}
public static class EffectAreaExtensions
{
static readonly Rect rectForCharacter = new Rect(0, 0, 1, 1);
static readonly Vector2 [] splitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
/// <summary>
/// Gets effect for area.
/// </summary>
public static Rect GetEffectArea (this EffectArea area, VertexHelper vh, Rect rectangle, float aspectRatio = -1)
{
Rect rect = default(Rect);
switch (area)
{
case EffectArea.RectTransform:
rect = rectangle;
break;
case EffectArea.Character:
rect = rectForCharacter;
break;
case EffectArea.Fit:
// Fit to contents.
UIVertex vertex = default (UIVertex);
float xMin = float.MaxValue;
float yMin = float.MaxValue;
float xMax = float.MinValue;
float yMax = float.MinValue;
for (int i = 0; i < vh.currentVertCount; i++)
{
vh.PopulateUIVertex(ref vertex, i);
float x = vertex.position.x;
float y = vertex.position.y;
xMin = Mathf.Min(xMin, x);
yMin = Mathf.Min(yMin, y);
xMax = Mathf.Max(xMax, x);
yMax = Mathf.Max(yMax, y);
}
rect.Set (xMin, yMin, xMax - xMin, yMax - yMin);
break;
default:
rect = rectangle;
break;
}
if(0 < aspectRatio)
{
if (rect.width < rect.height)
{
rect.width = rect.height * aspectRatio;
}
else
{
rect.height = rect.width / aspectRatio;
}
}
return rect;
}
/// <summary>
/// Gets position factor for area.
/// </summary>
public static void GetPositionFactor (this EffectArea area, int index, Rect rect, Vector2 position, bool isText, bool isTMPro, out float x, out float y)
{
if (isText && area == EffectArea.Character)
{
index = isTMPro ? (index + 3) % 4 : index % 4;
x = splitedCharacterPosition [index].x;
y = splitedCharacterPosition [index].y;
}
else if (area == EffectArea.Fit)
{
x = Mathf.Clamp01 ((position.x - rect.xMin) / rect.width);
y = Mathf.Clamp01 ((position.y - rect.yMin) / rect.height);
}
else
{
x = Mathf.Clamp01 (position.x / rect.width + 0.5f);
y = Mathf.Clamp01 (position.y / rect.height + 0.5f);
}
}
/// <summary>
/// Normalize vertex position by local matrix.
/// </summary>
public static void GetNormalizedFactor (this EffectArea area, int index, Matrix2x3 matrix, Vector2 position, bool isText, out Vector2 nomalizedPos)
{
if (isText && area == EffectArea.Character)
{
nomalizedPos = matrix * splitedCharacterPosition [(index + 3) % 4];
}
else
{
nomalizedPos = matrix * position;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a78f43d1382a048a99411472ca714e1b
timeCreated: 1528636556
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,156 @@
using UnityEngine;
using System;
using System.Collections.Generic;
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Effect player.
/// </summary>
[Serializable]
public class EffectPlayer
{
//################################
// Public Members.
//################################
/// <summary>
/// Gets or sets a value indicating whether is playing.
/// </summary>
[Header("Effect Player")]
[Tooltip("Playing.")]
public bool play = false;
/// <summary>
/// Gets or sets the delay before looping.
/// </summary>
[Tooltip("Initial play delay.")]
[Range(0f, 10f)]
public float initialPlayDelay = 0;
/// <summary>
/// Gets or sets the duration.
/// </summary>
[Tooltip("Duration.")]
[Range(0.01f,10f)]
public float duration = 1;
/// <summary>
/// Gets or sets a value indicating whether can loop.
/// </summary>
[Tooltip("Loop.")]
public bool loop = false;
/// <summary>
/// Gets or sets the delay before looping.
/// </summary>
[Tooltip("Delay before looping.")]
[Range(0f,10f)]
public float loopDelay = 0;
/// <summary>
/// Gets or sets the update mode.
/// </summary>
[Tooltip("Update mode")]
public AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal;
static List<Action> s_UpdateActions;
/// <summary>
/// Register player.
/// </summary>
public void OnEnable(Action<float> callback = null)
{
if (s_UpdateActions == null)
{
s_UpdateActions = new List<Action>();
Canvas.willRenderCanvases += () =>
{
var count = s_UpdateActions.Count;
for (int i = 0; i < count; i++)
{
s_UpdateActions[i].Invoke();
}
};
}
s_UpdateActions.Add(OnWillRenderCanvases);
if (play)
{
_time = -initialPlayDelay;
}
else
{
_time = 0;
}
_callback = callback;
}
/// <summary>
/// Unregister player.
/// </summary>
public void OnDisable()
{
_callback = null;
s_UpdateActions.Remove(OnWillRenderCanvases);
}
/// <summary>
/// Start playing.
/// </summary>
public void Play(bool reset, Action<float> callback = null)
{
if (reset)
{
_time = 0;
}
play = true;
if (callback != null)
{
_callback = callback;
}
}
/// <summary>
/// Stop playing.
/// </summary>
public void Stop(bool reset)
{
if (reset)
{
_time = 0;
if (_callback != null)
{
_callback(_time);
}
}
play = false;
}
//################################
// Private Members.
//################################
float _time = 0;
Action<float> _callback;
void OnWillRenderCanvases()
{
if (!play || !Application.isPlaying || _callback == null)
{
return;
}
_time += updateMode == AnimatorUpdateMode.UnscaledTime
? Time.unscaledDeltaTime
: Time.deltaTime;
var current = _time / duration;
if (duration <= _time)
{
play = loop;
_time = loop ? -loopDelay : 0;
}
_callback(current);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1656fb67110cd44298010d95c324e87a
timeCreated: 1528296875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,95 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect
{
public class MaterialCache
{
public ulong hash { get; private set; }
public int referenceCount { get; private set; }
public Texture texture { get; private set; }
public Material material { get; private set; }
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void ClearCache()
{
foreach (var cache in materialCaches)
{
cache.material = null;
}
materialCaches.Clear();
}
#endif
public static List<MaterialCache> materialCaches = new List<MaterialCache>();
public static MaterialCache Register(ulong hash, Texture texture, System.Func<Material> onCreateMaterial)
{
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
if (cache != null && cache.material)
{
if (cache.material)
{
cache.referenceCount++;
}
else
{
materialCaches.Remove(cache);
cache = null;
}
}
if (cache == null)
{
cache = new MaterialCache()
{
hash = hash,
material = onCreateMaterial(),
referenceCount = 1,
};
materialCaches.Add(cache);
}
return cache;
}
public static MaterialCache Register(ulong hash, System.Func<Material> onCreateMaterial)
{
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
if (cache != null)
{
cache.referenceCount++;
}
if (cache == null)
{
cache = new MaterialCache()
{
hash = hash,
material = onCreateMaterial(),
referenceCount = 1,
};
materialCaches.Add(cache);
}
return cache;
}
public static void Unregister(MaterialCache cache)
{
if (cache == null)
{
return;
}
cache.referenceCount--;
if (cache.referenceCount <= 0)
{
MaterialCache.materialCaches.Remove(cache);
cache.material = null;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2160d2c55a6100642b6c7ba09df935da
timeCreated: 1528509206
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,126 @@
#if UNITY_EDITOR
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect
{
public class MaterialResolver
{
static readonly StringBuilder s_StringBuilder = new StringBuilder();
static readonly Dictionary<string, Material> s_MaterialMap = new Dictionary<string, Material>();
public static Material GetOrGenerateMaterialVariant(Shader shader, params object[] append)
{
if (!shader)
{
return null;
}
Material mat = null;
string variantName = GetVariantName(shader, append);
if (s_MaterialMap.TryGetValue(variantName, out mat) && mat)
{
return mat;
}
string[] keywords = append.Where(x => 0 < (int)x)
.Select(x => x.ToString().ToUpper())
.ToArray();
mat = GetMaterial(shader, append);
if (mat)
{
if (!mat.shaderKeywords.OrderBy(x => x).SequenceEqual(keywords.OrderBy(x => x)))
{
mat.shaderKeywords = keywords;
EditorUtility.SetDirty(mat);
if (!Application.isPlaying)
{
EditorApplication.delayCall += AssetDatabase.SaveAssets;
}
}
return mat;
}
if (s_MaterialMap.TryGetValue(variantName, out mat) && mat)
{
return mat;
}
Debug.Log("Generate material : " + variantName);
mat = new Material(shader);
mat.shaderKeywords = keywords;
mat.name = variantName;
mat.hideFlags |= HideFlags.NotEditable;
s_MaterialMap[variantName] = mat;
bool isMainAsset = append.Cast<int>().All(x => x == 0);
EditorApplication.delayCall += () => SaveMaterial(mat, shader, isMainAsset);
return mat;
}
static void SaveMaterial(Material mat, Shader shader, bool isMainAsset)
{
string materialPath = GetDefaultMaterialPath(shader);
#if UIEFFECT_SEPARATE
string dir = Path.GetDirectoryName(materialPath);
materialPath = Path.Combine(Path.Combine(dir, "Separated"), mat.name + ".mat");
isMainAsset = true;
#endif
if (isMainAsset)
{
Directory.CreateDirectory(Path.GetDirectoryName(materialPath));
AssetDatabase.CreateAsset(mat, materialPath);
}
else
{
GetOrGenerateMaterialVariant(shader);
mat.hideFlags |= HideFlags.HideInHierarchy;
AssetDatabase.AddObjectToAsset(mat, materialPath);
}
AssetDatabase.SaveAssets();
}
public static Material GetMaterial(Shader shader, params object[] append)
{
string variantName = GetVariantName(shader, append);
return AssetDatabase.FindAssets("t:Material " + Path.GetFileName(shader.name))
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
.OfType<Material>()
.FirstOrDefault(x => x.name == variantName);
}
public static string GetDefaultMaterialPath(Shader shader)
{
var name = Path.GetFileName(shader.name);
return AssetDatabase.FindAssets("t:Material " + name)
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x) == name)
?? ("Assets/" + name + ".mat");
}
public static string GetVariantName(Shader shader, params object[] append)
{
s_StringBuilder.Length = 0;
#if UIEFFECT_SEPARATE
s_StringBuilder.Append("[Separated] ");
#endif
s_StringBuilder.Append(Path.GetFileName(shader.name));
foreach (object mode in append.Where(x=>0<(int)x))
{
s_StringBuilder.Append("-");
s_StringBuilder.Append(mode.ToString());
}
return s_StringBuilder.ToString();
}
}
}
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 70261fa2760d4c040ac28aebb1f155fb
timeCreated: 1528297353
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Matrix2x3.
/// </summary>
public struct Matrix2x3
{
public float m00, m01, m02, m10, m11, m12;
public Matrix2x3(Rect rect, float cos, float sin)
{
const float center = 0.5f;
float dx = -rect.xMin / rect.width - center;
float dy = -rect.yMin / rect.height - center;
m00 = cos / rect.width;
m01 = -sin / rect.height;
m02 = dx * cos - dy * sin + center;
m10 = sin / rect.width;
m11 = cos / rect.height;
m12 = dx * sin + dy * cos + center;
}
public static Vector2 operator*(Matrix2x3 m, Vector2 v)
{
return new Vector2(
(m.m00 * v.x) + (m.m01 * v.y) + m.m02,
(m.m10 * v.x) + (m.m11 * v.y) + m.m12
);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5a9b962044ca64867b713425f7e5daab
timeCreated: 1527590245
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class Packer
{
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(float x, float y, float z, float w)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
z = z < 0 ? 0 : 1 < z ? 1 : z;
w = w < 0 ? 0 : 1 < w ? 1 : w;
const int PRECISION = (1 << 6) - 1;
return (Mathf.FloorToInt(w * PRECISION) << 18)
+ (Mathf.FloorToInt(z * PRECISION) << 12)
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(Vector4 factor)
{
return ToFloat(Mathf.Clamp01(factor.x), Mathf.Clamp01(factor.y), Mathf.Clamp01(factor.z), Mathf.Clamp01(factor.w));
}
/// <summary>
/// Pack 1 middle-precision & 2 low-precision [0-1] floats values to a float.
/// z value [0-1] has 4096 steps(12 bits) and xy value [0-1] has 64 steps(6 bits).
/// </summary>
public static float ToFloat(float x, float y, float z)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
z = z < 0 ? 0 : 1 < z ? 1 : z;
const int PRECISION = (1 << 8) - 1;
return (Mathf.FloorToInt(z * PRECISION) << 16)
+ (Mathf.FloorToInt(y * PRECISION) << 8)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 2 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 4096 steps(12 bits).
/// </summary>
public static float ToFloat(float x, float y)
{
x = x < 0 ? 0 : 1 < x ? 1 : x;
y = y < 0 ? 0 : 1 < y ? 1 : y;
const int PRECISION = (1 << 12) - 1;
return (Mathf.FloorToInt(y * PRECISION) << 12)
+ Mathf.FloorToInt(x * PRECISION);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b4970b3a69d3b472b8d66c1d92ec7bad
timeCreated: 1527590285
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,190 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using System;
namespace Assets.Scripts.UI.UIEffect
{
public interface IParameterTexture
{
int parameterIndex { get; set; }
ParameterTexture ptex { get; }
}
/// <summary>
/// Parameter texture.
/// </summary>
[System.Serializable]
public class ParameterTexture
{
//################################
// Public Members.
//################################
/// <summary>
/// Initializes a new instance of the <see cref="Assets.Scripts.UI.UIEffect.ParameterTexture"/> class.
/// </summary>
/// <param name="channels">Channels.</param>
/// <param name="instanceLimit">Instance limit.</param>
/// <param name="propertyName">Property name.</param>
public ParameterTexture(int channels, int instanceLimit, string propertyName)
{
_propertyName = propertyName;
_channels = ((channels - 1) / 4 + 1) * 4;
_instanceLimit = ((instanceLimit - 1) / 2 + 1) * 2;
_data = new byte[_channels * _instanceLimit];
_stack = new Stack<int>(_instanceLimit);
for (int i = 1; i < _instanceLimit + 1; i++)
{
_stack.Push(i);
}
}
/// <summary>
/// Register the specified target.
/// </summary>
/// <param name="target">Target.</param>
public void Register(IParameterTexture target)
{
Initialize();
if (target.parameterIndex <= 0 && 0 < _stack.Count)
{
target.parameterIndex = _stack.Pop();
// Debug.LogFormat("<color=green>@@@ Register {0} : {1}</color>", target, target.parameterIndex);
}
}
/// <summary>
/// Unregister the specified target.
/// </summary>
/// <param name="target">Target.</param>
public void Unregister(IParameterTexture target)
{
if (0 < target.parameterIndex)
{
// Debug.LogFormat("<color=red>@@@ Unregister {0} : {1}</color>", target, target.parameterIndex);
_stack.Push(target.parameterIndex);
target.parameterIndex = 0;
}
}
/// <summary>
/// Sets the data.
/// </summary>
/// <param name="target">Target.</param>
/// <param name="channelId">Channel identifier.</param>
/// <param name="value">Value.</param>
public void SetData(IParameterTexture target, int channelId, byte value)
{
int index = (target.parameterIndex - 1) * _channels + channelId;
if (0 < target.parameterIndex && _data[index] != value)
{
_data[index] = value;
_needUpload = true;
}
}
/// <summary>
/// Sets the data.
/// </summary>
/// <param name="target">Target.</param>
/// <param name="channelId">Channel identifier.</param>
/// <param name="value">Value.</param>
public void SetData(IParameterTexture target, int channelId, float value)
{
SetData(target, channelId, (byte)(Mathf.Clamp01(value) * 255));
}
/// <summary>
/// Registers the material.
/// </summary>
/// <param name="mat">Mat.</param>
public void RegisterMaterial(Material mat)
{
if (_propertyId == 0)
{
_propertyId = Shader.PropertyToID(_propertyName);
}
if (mat)
{
mat.SetTexture(_propertyId, _texture);
}
}
/// <summary>
/// Gets the index of the normalized.
/// </summary>
/// <returns>The normalized index.</returns>
/// <param name="target">Target.</param>
public float GetNormalizedIndex(IParameterTexture target)
{
return ((float)target.parameterIndex - 0.5f) / _instanceLimit;
}
//################################
// Private Members.
//################################
Texture2D _texture;
bool _needUpload;
int _propertyId;
readonly string _propertyName;
readonly int _channels;
readonly int _instanceLimit;
readonly byte[] _data;
readonly Stack<int> _stack;
static List<Action> updates;
/// <summary>
/// Initialize this instance.
/// </summary>
void Initialize()
{
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
{
return;
}
#endif
if (updates == null)
{
updates = new List<Action>();
Canvas.willRenderCanvases += () =>
{
var count = updates.Count;
for (int i = 0; i < count; i++)
{
updates[i].Invoke();
}
};
}
if (!_texture)
{
bool isLinear = QualitySettings.activeColorSpace == ColorSpace.Linear;
_texture = new Texture2D(_channels / 4, _instanceLimit, TextureFormat.RGBA32, false, isLinear);
_texture.filterMode = FilterMode.Point;
_texture.wrapMode = TextureWrapMode.Clamp;
updates.Add(UpdateParameterTexture);
_needUpload = true;
}
}
void UpdateParameterTexture()
{
if (_needUpload && _texture)
{
_needUpload = false;
_texture.LoadRawTextureData(_data);
_texture.Apply(false, false);
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 65eafa89b3a3a494a99e185423ba6cad
timeCreated: 1533006319
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Shadow effect style.
/// </summary>
public enum ShadowStyle
{
None = 0,
Shadow,
Outline,
Outline8,
Shadow3,
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b0eda5bf10146491c9cfe6a31c66f9a7
timeCreated: 1528296875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Effect mode.
/// </summary>
public enum EffectMode
{
None = 0,
Grayscale = 1,
Sepia = 2,
Nega = 3,
Pixel = 4,
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 092769547c242d74cbad96631a00963f
timeCreated: 1528296875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,165 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts.UI.UIEffect
{
/// <summary>
/// Abstract effect base for UI.
/// </summary>
[DisallowMultipleComponent]
public abstract class UIEffectBase : BaseMeshEffect, IParameterTexture
#if UNITY_EDITOR
, ISerializationCallbackReceiver
#endif
{
protected static readonly Vector2[] splitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
protected static readonly List<UIVertex> tempVerts = new List<UIVertex>();
[HideInInspector]
[SerializeField] int m_Version;
[SerializeField] protected Material m_EffectMaterial;
/// <summary>
/// Gets or sets the parameter index.
/// </summary>
public int parameterIndex { get; set; }
/// <summary>
/// Gets the parameter texture.
/// </summary>
public virtual ParameterTexture ptex { get { return null; } }
/// <summary>
/// Gets target graphic for effect.
/// </summary>
public Graphic targetGraphic { get { return graphic; } }
/// <summary>
/// Gets material for effect.
/// </summary>
public Material effectMaterial { get { return m_EffectMaterial; } }
#if UNITY_EDITOR
protected override void Reset()
{
m_Version = 300;
OnValidate();
}
/// <summary>
/// Raises the validate event.
/// </summary>
protected override void OnValidate()
{
base.OnValidate ();
var mat = GetMaterial();
if (m_EffectMaterial != mat)
{
m_EffectMaterial = mat;
UnityEditor.EditorUtility.SetDirty(this);
}
ModifyMaterial();
SetVerticesDirty ();
SetDirty ();
}
public void OnBeforeSerialize()
{
}
public void OnAfterDeserialize()
{
UnityEditor.EditorApplication.delayCall += UpgradeIfNeeded;
}
protected bool IsShouldUpgrade(int expectedVersion)
{
if (m_Version < expectedVersion)
{
Debug.LogFormat(gameObject, "<b>{0}({1})</b> has been upgraded: <i>version {2} -> {3}</i>", name, GetType().Name, m_Version, expectedVersion);
m_Version = expectedVersion;
//UnityEditor.EditorApplication.delayCall += () =>
{
UnityEditor.EditorUtility.SetDirty(this);
if (!Application.isPlaying && gameObject && gameObject.scene.IsValid())
{
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(gameObject.scene);
}
}
;
return true;
}
return false;
}
protected virtual void UpgradeIfNeeded()
{
}
/// <summary>
/// Gets the material.
/// </summary>
/// <returns>The material.</returns>
protected virtual Material GetMaterial()
{
return null;
}
#endif
/// <summary>
/// Modifies the material.
/// </summary>
public virtual void ModifyMaterial()
{
targetGraphic.material = isActiveAndEnabled ? m_EffectMaterial : null;
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable ();
if (ptex != null)
{
ptex.Register(this);
}
ModifyMaterial();
SetVerticesDirty();
SetDirty();
}
/// <summary>
/// This function is called when the behaviour becomes disabled () or inactive.
/// </summary>
protected override void OnDisable()
{
base.OnDisable ();
ModifyMaterial ();
SetVerticesDirty();
if (ptex != null)
{
ptex.Unregister(this);
}
}
/// <summary>
/// Mark the UIEffect as dirty.
/// </summary>
protected virtual void SetDirty()
{
SetVerticesDirty();
}
protected override void OnDidApplyAnimationProperties()
{
SetDirty();
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e8b7ed62cf1444b4ebfc5e5338bc6682
timeCreated: 1485321967
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ee1bfc8c299e6482cb7175ba2f94495a
folderAsset: yes
timeCreated: 1487152270
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect.Editors
{
public class BaseMeshEffectEditor : Editor
{
List<MaterialEditor> _materialEditors = new List<MaterialEditor> ();
protected virtual void OnEnable ()
{
ClearMaterialEditors ();
}
protected virtual void OnDisable ()
{
ClearMaterialEditors ();
}
void ClearMaterialEditors ()
{
foreach (var e in _materialEditors)
{
if (e)
{
DestroyImmediate (e);
}
}
_materialEditors.Clear ();
}
protected void ShowMaterialEditors (Material [] materials, int startIndex, int count)
{
for (int i = 0; i < count; i++)
{
if (_materialEditors.Count == i)
{
_materialEditors.Add (null);
}
var mat = materials [startIndex + i];
var editor = _materialEditors [i];
if (editor && editor.target != mat)
{
DestroyImmediate (editor);
editor = null;
}
if (!editor)
{
editor = _materialEditors [i] = Editor.CreateEditor (mat) as MaterialEditor;
}
editor.DrawHeader ();
editor.OnInspectorGUI ();
}
}
protected void ShowCanvasChannelsWarning ()
{
BaseMeshEffect effect = target as BaseMeshEffect;
if (!effect || !effect.graphic)
{
return;
}
#if UNITY_5_6_OR_NEWER
AdditionalCanvasShaderChannels channels = effect.requiredChannels;
var canvas = effect.graphic.canvas;
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
{
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.HelpBox (string.Format ("Enable {1} of Canvas.additionalShaderChannels to use {0}.", effect.GetType ().Name, channels), MessageType.Warning);
if (GUILayout.Button ("Fix"))
{
canvas.additionalShaderChannels |= channels;
}
EditorGUILayout.EndHorizontal ();
}
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ddf2f64ff7af4a9f9b5ba45f40302bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// Remove deprecated files in old .unitypackage, after compiling.
/// </summary>
public class DeprecatedRemover
{
/// <summary>
/// GUIDs of deprecated files.
/// </summary>
static readonly List<string> DeprecatedFiles = new List<string>()
{
"156b57fee6ef941958e66a129ce387e2", // UICustomEffect.cs
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
"7b1ed09bdf5e54042b5cd1fbe69361bf", // MaterialBundle.cs
};
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void RemoveFiles()
{
// The deprecated file path that exists.
var files = DeprecatedFiles.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Where(x => File.Exists(x))
.ToArray();
if (files.Any())
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<b><color=orange>[{0}]</color></b> {1} files have been removed.\n", typeof(DeprecatedRemover).Name, files.Length);
foreach (var path in files)
{
AssetDatabase.DeleteAsset(path);
sb.AppendFormat(" - {0}\n", path);
}
AssetDatabase.Refresh();
UnityEngine.Debug.Log(sb);
}
}
#endif
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6955fce24c79542af9ba39b3cf6f610f
timeCreated: 1536108312
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,181 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
using UnityEngine.UI;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIDissolve))]
[CanEditMultipleObjects]
public class UIDissolveEditor : BaseMeshEffectEditor
{
static int s_NoiseTexId;
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable ();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spWidth = serializedObject.FindProperty("m_Width");
_spColor = serializedObject.FindProperty("m_Color");
_spSoftness = serializedObject.FindProperty("m_Softness");
_spColorMode = serializedObject.FindProperty("m_ColorMode");
_spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spReverse = serializedObject.FindProperty("m_Reverse");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
s_NoiseTexId = Shader.PropertyToID ("_NoiseTex");
_shader = Shader.Find ("TextMeshPro/Distance Field (UIDissolve)");
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIDissolve)");
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIDissolve)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UIDissolve> ())
{
var mat = d.material;
if (d.isTMPro && mat && mat.HasProperty(s_NoiseTexId))
{
ColorMode colorMode =
mat.IsKeywordEnabled ("ADD") ? ColorMode.Add
: mat.IsKeywordEnabled ("SUBTRACT") ? ColorMode.Subtract
: mat.IsKeywordEnabled ("FILL") ? ColorMode.Fill
: ColorMode.Multiply;
Texture noiseTexture = mat.GetTexture(s_NoiseTexId);
if (d.colorMode != colorMode || d.noiseTexture != noiseTexture)
{
var so = new SerializedObject (d);
so.FindProperty ("m_ColorMode").intValue = (int)colorMode;
so.FindProperty ("m_NoiseTexture").objectReferenceValue = noiseTexture;
so.ApplyModifiedProperties ();
}
}
}
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spEffectFactor);
EditorGUILayout.PropertyField(_spWidth);
EditorGUILayout.PropertyField(_spSoftness);
EditorGUILayout.PropertyField(_spColor);
bool isAnyTMPro = targets.Cast<UIDissolve>().Any(x => x.isTMPro);
using (new EditorGUI.DisabledGroupScope (isAnyTMPro))
{
EditorGUILayout.PropertyField (_spColorMode);
EditorGUILayout.PropertyField (_spNoiseTexture);
}
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
EditorGUILayout.PropertyField(_spKeepAspectRatio);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
EditorGUILayout.PropertyField(_spReverse);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Play", "ButtonLeft"))
{
(target as UIDissolve).Play();
}
if (GUILayout.Button("Stop", "ButtonRight"))
{
(target as UIDissolve).Stop();
}
}
var c = target as UIDissolve;
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {
if(mat.shader == _spriteShader)
{
mat.shaderKeywords = c.material.shaderKeywords;
mat.SetTexture ("_NoiseTex", c.material.GetTexture ("_NoiseTex"));
}
});
ShowCanvasChannelsWarning ();
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectFactor;
SerializedProperty _spWidth;
SerializedProperty _spColor;
SerializedProperty _spSoftness;
SerializedProperty _spColorMode;
SerializedProperty _spNoiseTexture;
SerializedProperty _spEffectArea;
SerializedProperty _spKeepAspectRatio;
SerializedProperty _spReverse;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f7f7349a5d61649b69946853317db047
timeCreated: 1538806040
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,188 @@
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using DesamplingRate = Assets.Scripts.UI.UIEffect.UIEffectCapturedImage.DesamplingRate;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffectCapturedImage editor.
/// </summary>
[CustomEditor(typeof(UIEffectCapturedImage))]
[CanEditMultipleObjects]
public class UIEffectCapturedImageEditor : RawImageEditor
{
//################################
// Constant or Static Members.
//################################
public enum QualityMode : int
{
Fast = (DesamplingRate.x2 << 0) + (DesamplingRate.x2 << 4) + (FilterMode.Bilinear << 8) + (2 << 10),
Medium = (DesamplingRate.x1 << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (3 << 10),
Detail = (DesamplingRate.None << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (5 << 10),
Custom = -1,
}
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spTexture = serializedObject.FindProperty("m_Texture");
_spColor = serializedObject.FindProperty("m_Color");
_spRaycastTarget = serializedObject.FindProperty("m_RaycastTarget");
_spDesamplingRate = serializedObject.FindProperty("m_DesamplingRate");
_spReductionRate = serializedObject.FindProperty("m_ReductionRate");
_spFilterMode = serializedObject.FindProperty("m_FilterMode");
_spIterations = serializedObject.FindProperty("m_BlurIterations");
_spKeepSizeToRootCanvas = serializedObject.FindProperty("m_FitToScreen");
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
_spCaptureOnEnable = serializedObject.FindProperty("m_CaptureOnEnable");
_customAdvancedOption = (qualityMode == QualityMode.Custom);
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
var graphic = (target as UIEffectCapturedImage);
serializedObject.Update();
//================
// Basic properties.
//================
EditorGUILayout.PropertyField(_spTexture);
EditorGUILayout.PropertyField(_spColor);
EditorGUILayout.PropertyField(_spRaycastTarget);
//================
// Capture effect.
//================
GUILayout.Space(10);
EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
UIEffectEditor.DrawEffectProperties(serializedObject, "m_EffectColor");
//================
// Advanced option.
//================
GUILayout.Space(10);
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_spCaptureOnEnable);// CaptureOnEnable.
EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);// Keep Graphic Size To RootCanvas.
EditorGUI.BeginChangeCheck();
QualityMode quality = qualityMode;
quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
if (EditorGUI.EndChangeCheck())
{
_customAdvancedOption = (quality == QualityMode.Custom);
qualityMode = quality;
}
// When qualityMode is `Custom`, show advanced option.
if (_customAdvancedOption)
{
if (_spBlurMode.intValue != 0)
{
EditorGUILayout.PropertyField(_spIterations);// Iterations.
}
DrawDesamplingRate(_spReductionRate);// Reduction rate.
EditorGUILayout.Space();
EditorGUILayout.LabelField("Result Texture Setting", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
}
serializedObject.ApplyModifiedProperties();
// Debug.
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Capture", "ButtonLeft"))
{
graphic.Release();
EditorApplication.delayCall += graphic.Capture;
}
EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
if (GUILayout.Button("Release", "ButtonRight"))
{
graphic.Release();
}
EditorGUI.EndDisabledGroup();
}
}
//################################
// Private Members.
//################################
const int Bits4 = (1 << 4) - 1;
const int Bits2 = (1 << 2) - 1;
bool _customAdvancedOption = false;
SerializedProperty _spTexture;
SerializedProperty _spColor;
SerializedProperty _spRaycastTarget;
SerializedProperty _spDesamplingRate;
SerializedProperty _spReductionRate;
SerializedProperty _spFilterMode;
SerializedProperty _spBlurMode;
SerializedProperty _spIterations;
SerializedProperty _spKeepSizeToRootCanvas;
SerializedProperty _spCaptureOnEnable;
QualityMode qualityMode
{
get
{
if (_customAdvancedOption)
return QualityMode.Custom;
int qualityValue = (_spDesamplingRate.intValue << 0)
+ (_spReductionRate.intValue << 4)
+ (_spFilterMode.intValue << 8)
+ (_spIterations.intValue << 10);
return System.Enum.IsDefined(typeof(QualityMode), qualityValue) ? (QualityMode)qualityValue : QualityMode.Custom;
}
set
{
if (value != QualityMode.Custom)
{
int qualityValue = (int)value;
_spDesamplingRate.intValue = (qualityValue >> 0) & Bits4;
_spReductionRate.intValue = (qualityValue >> 4) & Bits4;
_spFilterMode.intValue = (qualityValue >> 8) & Bits2;
_spIterations.intValue = (qualityValue >> 10) & Bits4;
}
}
}
/// <summary>
/// Draws the desampling rate.
/// </summary>
void DrawDesamplingRate(SerializedProperty sp)
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(sp);
int w, h;
(target as UIEffectCapturedImage).GetDesamplingSize((UIEffectCapturedImage.DesamplingRate)sp.intValue, out w, out h);
GUILayout.Label(string.Format("{0}x{1}", w, h), EditorStyles.miniLabel);
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2476309c9b71d614ab97a2f9651b3333
timeCreated: 1487152293
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,253 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Linq;
using System;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIEffect))]
[CanEditMultipleObjects]
public class UIEffectEditor : BaseMeshEffectEditor
{
static readonly GUIContent contentEffectColor = new GUIContent ("Effect Color");
//################################
// Public/Protected Members.
//################################
/// <summary>
/// Draw effect properties.
/// </summary>
public static void DrawEffectProperties(SerializedObject serializedObject, string colorProperty = "m_Color")
{
//================
// Effect material.
//================
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
var spToneMode = serializedObject.FindProperty("m_EffectMode");
EditorGUILayout.PropertyField(spToneMode);
// When tone is enable, show parameters.
if (spToneMode.intValue != (int)EffectMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
EditorGUI.indentLevel--;
}
//================
// Color setting.
//================
var spColorMode = serializedObject.FindProperty("m_ColorMode");
EditorGUILayout.PropertyField(spColorMode);
// When color is enable, show parameters.
//if (spColorMode.intValue != (int)ColorMode.Multiply)
{
EditorGUI.indentLevel++;
SerializedProperty spColor = serializedObject.FindProperty(colorProperty);
if (spColor == null && serializedObject.targetObject is UIEffect) {
spColor = new SerializedObject (serializedObject.targetObjects.Select(x=>(x as UIEffect).targetGraphic).ToArray()).FindProperty(colorProperty);
}
EditorGUI.BeginChangeCheck ();
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
#if UNITY_2018_1_OR_NEWER
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false);
#else
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
#endif
if (EditorGUI.EndChangeCheck ()) {
spColor.serializedObject.ApplyModifiedProperties ();
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
EditorGUI.indentLevel--;
}
//================
// Blur setting.
//================
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
EditorGUILayout.PropertyField(spBlurMode);
// When blur is enable, show parameters.
if (spBlurMode.intValue != (int)BlurMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
if (spAdvancedBlur != null)
{
EditorGUILayout.PropertyField(spAdvancedBlur);
}
EditorGUI.indentLevel--;
}
}
int GetEnum<T>(Material mat)
{
Type type = typeof(T);
string[] names = System.Enum.GetNames (type);
int[] values = System.Enum.GetValues (type) as int[];
int mode = 0;
for(int i=0;i<names.Length;i++)
{
if (mat.IsKeywordEnabled (names [i].ToUpper()))
mode = values [i];
}
return mode;
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UIEffect> ())
{
var mat = d.material;
if (d.isTMPro && mat)
{
var so = new SerializedObject (d);
EffectMode eMode = (EffectMode)GetEnum<EffectMode> (mat);
ColorMode cMode = (ColorMode)GetEnum<ColorMode> (mat);
BlurMode bMode = (BlurMode)GetEnum<BlurMode> (mat);
bool aBlur = mat.IsKeywordEnabled("EX");
if (d.effectMode != eMode || d.colorMode != cMode || d.blurMode != bMode || so.FindProperty ("m_AdvancedBlur").boolValue != aBlur)
{
so.FindProperty ("m_EffectMode").intValue = (int)eMode;
so.FindProperty ("m_ColorMode").intValue = (int)cMode;
so.FindProperty ("m_BlurMode").intValue = (int)bMode;
so.FindProperty ("m_AdvancedBlur").boolValue = aBlur;
so.ApplyModifiedProperties ();
}
}
}
serializedObject.Update();
bool isAnyTMPro = targets.Cast<UIEffect>().Any(x => x.isTMPro);
var c = target as UIEffect;
//================
// Effect material.
//================
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
var spToneMode = serializedObject.FindProperty("m_EffectMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spToneMode);
// When tone is enable, show parameters.
if (spToneMode.intValue != (int)EffectMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
EditorGUI.indentLevel--;
}
//================
// Color setting.
//================
var spColorMode = serializedObject.FindProperty("m_ColorMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spColorMode);
// When color is enable, show parameters.
//if (spColorMode.intValue != (int)ColorMode.Multiply)
{
EditorGUI.indentLevel++;
SerializedProperty spColor = serializedObject.FindProperty("m_Color");
if (spColor == null && serializedObject.targetObject is UIEffect) {
spColor = new SerializedObject (serializedObject.targetObjects.Select(x=>(x as UIEffect).targetGraphic).ToArray()).FindProperty(!isAnyTMPro ? "m_Color" : "m_fontColor");
}
EditorGUI.BeginChangeCheck ();
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
#if UNITY_2018_1_OR_NEWER
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false);
#else
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
#endif
if (EditorGUI.EndChangeCheck ()) {
spColor.serializedObject.ApplyModifiedProperties ();
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
EditorGUI.indentLevel--;
}
//================
// Blur setting.
//================
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spBlurMode);
// When blur is enable, show parameters.
if (spBlurMode.intValue != (int)BlurMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(spAdvancedBlur);
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
ShowCanvasChannelsWarning ();
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable ();
_shader = Shader.Find ("TextMeshPro/Distance Field (UIEffect)");
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIEffect)");
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIEffect)");
}
//################################
// Private Members.
//################################
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4f7e9f2ce1cb543ca88606769affbe24
timeCreated: 1487152293
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,102 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIGradient))]
[CanEditMultipleObjects]
public class UIGradientEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Direction.
//================
var spDirection = serializedObject.FindProperty("m_Direction");
EditorGUILayout.PropertyField(spDirection);
//================
// Color.
//================
var spColor1 = serializedObject.FindProperty("m_Color1");
var spColor2 = serializedObject.FindProperty("m_Color2");
var spColor3 = serializedObject.FindProperty("m_Color3");
var spColor4 = serializedObject.FindProperty("m_Color4");
switch ((UIGradient.Direction)spDirection.intValue)
{
case UIGradient.Direction.Horizontal:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Left"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Right"));
break;
case UIGradient.Direction.Vertical:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Top"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Bottom"));
break;
case UIGradient.Direction.Angle:
EditorGUILayout.PropertyField(spColor1, new GUIContent("Color 1"));
EditorGUILayout.PropertyField(spColor2, new GUIContent("Color 2"));
break;
case UIGradient.Direction.Diagonal:
Rect r = EditorGUILayout.GetControlRect(false, 34);
r = EditorGUI.PrefixLabel(r, new GUIContent("Diagonal Color"));
float w = r.width / 2;
EditorGUI.PropertyField(new Rect(r.x, r.y, w, 16), spColor3, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x + w, r.y, w, 16), spColor4, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x, r.y + 18, w, 16), spColor1, GUIContent.none);
EditorGUI.PropertyField(new Rect(r.x + w, r.y + 18, w, 16), spColor2, GUIContent.none);
break;
}
//================
// Angle.
//================
if ((int)UIGradient.Direction.Angle <= spDirection.intValue)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Rotation"));
}
//================
// Offset.
//================
if ((int)UIGradient.Direction.Diagonal == spDirection.intValue)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Vertical Offset"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset2"), new GUIContent("Horizontal Offset"));
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Offset"));
}
//================
// Advanced options.
//================
EditorGUILayout.Space();
EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
{
//if ((target as UIGradient).targetGraphic is Text)
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_GradientStyle"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorSpace"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_IgnoreAspectRatio"));
}
EditorGUI.indentLevel--;
serializedObject.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c28dcc885fbba4a5187a6a1aa5fb1b3b
timeCreated: 1515895646
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Linq;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIHsvModifier))]
[CanEditMultipleObjects]
public class UIHsvModifierEditor : BaseMeshEffectEditor
{
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable ();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spTargetColor = serializedObject.FindProperty("m_TargetColor");
_spRange = serializedObject.FindProperty("m_Range");
_spHue = serializedObject.FindProperty("m_Hue");
_spSaturation = serializedObject.FindProperty("m_Saturation");
_spValue = serializedObject.FindProperty("m_Value");
_shader = Shader.Find ("TextMeshPro/Distance Field (UIHsvModifier)");
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIHsvModifier)");
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIHsvModifier)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spTargetColor);
EditorGUILayout.PropertyField(_spRange);
EditorGUILayout.PropertyField(_spHue);
EditorGUILayout.PropertyField(_spSaturation);
EditorGUILayout.PropertyField(_spValue);
var c = target as UIHsvModifier;
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
ShowCanvasChannelsWarning ();
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spTargetColor;
SerializedProperty _spRange;
SerializedProperty _spHue;
SerializedProperty _spSaturation;
SerializedProperty _spValue;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f002ba0ac474d487b936bc046dda56b4
timeCreated: 1538806052
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,54 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIShadow editor.
/// </summary>
[CustomEditor(typeof(UIShadow))]
[CanEditMultipleObjects]
public class UIShadowEditor : Editor
{
UIEffect uiEffect;
void OnEnable()
{
uiEffect = (target as UIShadow).GetComponent<UIEffect>();
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Shadow setting.
//================
var spShadowMode = serializedObject.FindProperty("m_Style");
EditorGUILayout.PropertyField(spShadowMode);
// When shadow is enable, show parameters.
if (spShadowMode.intValue != (int)ShadowStyle.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectDistance"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
if (uiEffect && uiEffect.blurMode != BlurMode.None)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
}
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e76e7f628f09af449321b4776123f13
timeCreated: 1487152293
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,135 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Linq;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIShiny))]
[CanEditMultipleObjects]
public class UIShinyEditor : BaseMeshEffectEditor
{
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable ();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spWidth = serializedObject.FindProperty("m_Width");
_spRotation = serializedObject.FindProperty("m_Rotation");
_spSoftness = serializedObject.FindProperty("m_Softness");
_spBrightness = serializedObject.FindProperty("m_Brightness");
_spGloss = serializedObject.FindProperty("m_Gloss");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
_shader = Shader.Find ("TextMeshPro/Distance Field (UIShiny)");
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIShiny)");
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIShiny)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
EditorGUILayout.PropertyField(_spEffectFactor);
EditorGUILayout.PropertyField(_spWidth);
EditorGUILayout.PropertyField(_spRotation);
EditorGUILayout.PropertyField(_spSoftness);
EditorGUILayout.PropertyField(_spBrightness);
EditorGUILayout.PropertyField(_spGloss);
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Play", "ButtonLeft"))
{
(target as UIShiny).Play();
}
if (GUILayout.Button("Stop", "ButtonRight"))
{
(target as UIShiny).Stop();
}
}
var c = target as UIShiny;
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
ShowCanvasChannelsWarning ();
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectFactor;
SerializedProperty _spWidth;
SerializedProperty _spRotation;
SerializedProperty _spSoftness;
SerializedProperty _spBrightness;
SerializedProperty _spGloss;
SerializedProperty _spEffectArea;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0080e984bad7545cd957d9121e99f988
timeCreated: 1538806052
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,190 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using System.Linq;
namespace Assets.Scripts.UI.UIEffect.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UITransitionEffect))]
[CanEditMultipleObjects]
public class UITransitionEffectEditor : BaseMeshEffectEditor
{
static int s_NoiseTexId;
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
_spEffectMode = serializedObject.FindProperty("m_EffectMode");
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
_spDissolveWidth = serializedObject.FindProperty("m_DissolveWidth");
_spDissolveSoftness = serializedObject.FindProperty("m_DissolveSoftness");
_spDissolveColor = serializedObject.FindProperty("m_DissolveColor");
_spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture");
var player = serializedObject.FindProperty("m_Player");
_spPlay = player.FindPropertyRelative("play");
_spDuration = player.FindPropertyRelative("duration");
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
_spLoop = player.FindPropertyRelative("loop");
_spLoopDelay = player.FindPropertyRelative("loopDelay");
_spUpdateMode = player.FindPropertyRelative("updateMode");
_spPassRayOnHidden = serializedObject.FindProperty("m_PassRayOnHidden");
s_NoiseTexId = Shader.PropertyToID("_NoiseTex");
_shader = Shader.Find("TextMeshPro/Distance Field (UITransition)");
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UITransition)");
_spriteShader = Shader.Find("TextMeshPro/Sprite (UITransition)");
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
foreach (var d in targets.Cast<UITransitionEffect> ())
{
var mat = d.material;
if (d.isTMPro && mat && mat.HasProperty (s_NoiseTexId))
{
Texture noiseTexture = mat.GetTexture (s_NoiseTexId);
UITransitionEffect.EffectMode mode =
mat.IsKeywordEnabled ("CUTOFF") ? UITransitionEffect.EffectMode.Cutoff
: mat.IsKeywordEnabled ("FADE") ? UITransitionEffect.EffectMode.Fade
: mat.IsKeywordEnabled ("DISSOLVE") ? UITransitionEffect.EffectMode.Dissolve
: (UITransitionEffect.EffectMode)0;
if (mode == (UITransitionEffect.EffectMode)0)
{
mode = UITransitionEffect.EffectMode.Cutoff;
mat.EnableKeyword ("CUTOFF");
}
bool hasChanged = d.transitionTexture != noiseTexture || d.effectMode != mode;
if (hasChanged)
{
var so = new SerializedObject (d);
so.FindProperty ("m_TransitionTexture").objectReferenceValue = noiseTexture;
so.FindProperty ("m_EffectMode").intValue = (int)mode;
so.ApplyModifiedProperties ();
}
}
}
serializedObject.Update();
//================
// Effect material.
//================
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(_spMaterial);
EditorGUI.EndDisabledGroup();
//================
// Effect setting.
//================
bool isAnyTMPro = targets.Cast<UITransitionEffect>().Any(x => x.isTMPro);
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(_spEffectMode);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_spEffectFactor);
if (_spEffectMode.intValue == (int)UITransitionEffect.EffectMode.Dissolve)
{
EditorGUILayout.PropertyField(_spDissolveWidth);
EditorGUILayout.PropertyField(_spDissolveSoftness);
EditorGUILayout.PropertyField(_spDissolveColor);
}
EditorGUI.indentLevel--;
//================
// Advanced option.
//================
EditorGUILayout.PropertyField(_spEffectArea);
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
EditorGUILayout.PropertyField(_spTransitionTexture);
EditorGUILayout.PropertyField(_spKeepAspectRatio);
EditorGUILayout.PropertyField(_spPassRayOnHidden);
//================
// Effect player.
//================
EditorGUILayout.PropertyField(_spPlay);
EditorGUILayout.PropertyField(_spDuration);
EditorGUILayout.PropertyField(_spInitialPlayDelay);
EditorGUILayout.PropertyField(_spLoop);
EditorGUILayout.PropertyField(_spLoopDelay);
EditorGUILayout.PropertyField(_spUpdateMode);
// Debug.
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
{
GUILayout.Label("Debug");
if (GUILayout.Button("Show", "ButtonLeft"))
{
(target as UITransitionEffect).Show();
}
if (GUILayout.Button("Hide", "ButtonRight"))
{
(target as UITransitionEffect).Hide();
}
}
var current = target as UITransitionEffect;
current.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat =>
{
if (mat.shader == _spriteShader)
{
mat.shaderKeywords = current.material.shaderKeywords;
mat.SetTexture(s_NoiseTexId, current.material.GetTexture(s_NoiseTexId));
}
});
ShowCanvasChannelsWarning();
ShowMaterialEditors(current.materials, 1, current.materials.Length - 1);
serializedObject.ApplyModifiedProperties();
}
//################################
// Private Members.
//################################
SerializedProperty _spMaterial;
SerializedProperty _spEffectMode;
SerializedProperty _spEffectFactor;
SerializedProperty _spEffectArea;
SerializedProperty _spKeepAspectRatio;
SerializedProperty _spDissolveWidth;
SerializedProperty _spDissolveSoftness;
SerializedProperty _spDissolveColor;
SerializedProperty _spTransitionTexture;
SerializedProperty _spPlay;
SerializedProperty _spLoop;
SerializedProperty _spLoopDelay;
SerializedProperty _spDuration;
SerializedProperty _spInitialPlayDelay;
SerializedProperty _spUpdateMode;
SerializedProperty _spPassRayOnHidden;
Shader _shader;
Shader _mobileShader;
Shader _spriteShader;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 631f363a54c834f1f846f823b31bd321
timeCreated: 1538806067
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7af5e5d189eb4d9479f0a083078f4946
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,238 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 8
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21162286589123374
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Fill
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: FILL
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21841578701121694
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Subtract
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: SUBTRACT
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21939717441729078
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Add
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: ADD
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17b17d6effbe14075a3bbdf1fda1f6e1
timeCreated: 1526828325
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-HSV
m_Shader: {fileID: 4800000, guid: 7fc74090480c84f8b977cfcd55cdfe82, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _BumpScale
second: 1
- first:
name: _ColorMask
second: 15
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DstBlend
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _Metallic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 1
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UVSec
second: 0
- first:
name: _UseUIAlphaClip
second: 0
- first:
name: _ZWrite
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c8243c28075b3431084ded42f46ad567
timeCreated: 1531885800
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Shiny
m_Shader: {fileID: 4800000, guid: 20ffe76c2439c403aabdd25bd94bf011, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParamTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9dc7e810a87b444ab96919f3215c2fe5
timeCreated: 1523859834
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77a4cc77ec7394415a18f9e5a4b8083e
timeCreated: 1532512709
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aee96bc531e6eba468ec405e536f515f
timeCreated: 1516545204
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1a1a8e44196ca754a9a7b9cb80e17573
timeCreated: 1516545204
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@@ -0,0 +1,100 @@
fileFormatVersion: 2
guid: 3e04c247fb2604af186173fce0bc62de
timeCreated: 1524468976
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
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:
filterMode: 1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
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: 2
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 10
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 256
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 256
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 256
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 256
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 256
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

@@ -0,0 +1,100 @@
fileFormatVersion: 2
guid: a74d3d4a498866d44b094d3d3717604d
timeCreated: 1533229728
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
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:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
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: 2
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 10
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 512
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 512
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 512
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 512
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 512
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03d05f9ad08aca246bc6462bb5972549
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,88 @@
Shader "UI/Hidden/UI-Effect-Dissolve"
{
Properties
{
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
_ParamTex ("Parameter Texture", 2D) = "white" {}
[Header(Dissolve)]
_NoiseTex("Noise Texture (A)", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#define DISSOLVE 1
#pragma multi_compile __ UNITY_UI_ALPHACLIP
#pragma shader_feature __ ADD SUBTRACT FILL
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#define UI_DISSOLVE 1
#include "UI-Effect.cginc"
#include "UI-Effect-Sprite.cginc"
fixed4 frag(v2f IN) : SV_Target
{
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
// Dissolve
color = ApplyTransitionEffect(color, IN.eParam);
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1b48dc831eb147e9886c049033213bf
timeCreated: 1523859834
licenseType: Pro
ShaderImporter:
defaultTextures:
- _MainTex: {instanceID: 0}
- _NoiseTex: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,79 @@
Shader "UI/Hidden/UI-Effect-HSV"
{
Properties
{
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
_ParamTex ("Parameter Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ UNITY_UI_ALPHACLIP
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#define UI_HSV_MODIFIER 1
#include "UI-Effect.cginc"
#include "UI-Effect-Sprite.cginc"
fixed4 frag(v2f IN) : COLOR
{
half4 color = tex2D(_MainTex, IN.texcoord);// + _TextureSampleAdd) * IN.color;
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
color = ApplyHsvEffect(color, IN.eParam);
return (color + _TextureSampleAdd) * IN.color;
}
ENDCG
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fc74090480c84f8b977cfcd55cdfe82
timeCreated: 1531882595
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,82 @@
Shader "UI/Hidden/UI-Effect-Shiny"
{
Properties
{
[PerRendererData] _MainTex ("Main Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
_ParamTex ("Parameter Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile __ UNITY_UI_ALPHACLIP
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#define UI_SHINY 1
#include "UI-Effect.cginc"
#include "UI-Effect-Sprite.cginc"
fixed4 frag(v2f IN) : SV_Target
{
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
color = ApplyShinyEffect(color, IN.eParam);
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
return color;
}
ENDCG
}
}
}
Loaded 100 of 401 files, more files were not shown because too many files have changed in this diff. Show more