加确认框。按钮加tooltips。调整大地图tips的位置。
This commit is contained in:
1 parent
bb4fabc833
commit
1c712ff7d5
18 files changed
+2401
-520
No files matched your search
@@ -11,9 +11,22 @@ namespace Assets.Scripts.UI.Control
|
||||
[RequireComponent(typeof(Text))]
|
||||
public class PFUIText : PFUIComponentBase
|
||||
{
|
||||
private Text text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text.text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text.text = value;
|
||||
}
|
||||
}
|
||||
protected void Awake()
|
||||
{
|
||||
|
||||
text = this.transform.GetComponent<Text>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
@@ -16,14 +18,18 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
Normal,
|
||||
Border,
|
||||
Primary
|
||||
Primary,
|
||||
Image
|
||||
}
|
||||
|
||||
[SerializeField] Type mType;
|
||||
[SerializeField] string Tooltips;
|
||||
private GameObject tooltips;
|
||||
private Image image;
|
||||
public Text text;
|
||||
private Texture2D cursor;
|
||||
private Text text;
|
||||
//private Texture2D cursor;
|
||||
private Outline outline;
|
||||
private Button mButton;
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
@@ -35,19 +41,35 @@ namespace Assets.Scripts.UI.Control
|
||||
}
|
||||
|
||||
//设置光标
|
||||
cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
|
||||
//cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
|
||||
|
||||
image = gameObject.GetComponent<Image>();
|
||||
text = this.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
if(mType == Type.Image)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
text.gameObject.SetActive(false);
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height*0.5f, 0));
|
||||
image.material = material;
|
||||
else
|
||||
{
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
|
||||
image.material = material;
|
||||
}
|
||||
|
||||
tooltips = this.transform.Find("Tooltips").gameObject;
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
//
|
||||
tooltips.transform.Find("Text").GetComponent<Text>().text = Tooltips;
|
||||
}
|
||||
tooltips.SetActive(false);
|
||||
|
||||
mButton = this.GetComponent<Button>();
|
||||
|
||||
InitColor();
|
||||
BindEvent();
|
||||
@@ -87,8 +109,13 @@ namespace Assets.Scripts.UI.Control
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerEnter, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
//Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
tooltips.GetComponent<CanvasGroup>().alpha = 0f;
|
||||
tooltips.SetActive(true);
|
||||
tooltips.GetComponent<CanvasGroup>().DOFade(1f, 0.2f);
|
||||
}
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
@@ -112,10 +139,14 @@ namespace Assets.Scripts.UI.Control
|
||||
}));
|
||||
|
||||
//鼠标离开
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
tooltips.SetActive(false);
|
||||
}
|
||||
//Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
@@ -170,7 +201,7 @@ namespace Assets.Scripts.UI.Control
|
||||
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerUp, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
//Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
@@ -200,6 +231,7 @@ namespace Assets.Scripts.UI.Control
|
||||
public void SetEnabled(bool value)
|
||||
{
|
||||
base.enabled = value;
|
||||
mButton.enabled = value;
|
||||
if (base.enabled)
|
||||
{
|
||||
InitColor();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Tips : MonoBehaviour
|
||||
this.GetComponent<Image>().material = material;
|
||||
|
||||
Name = this.transform.Find("Name").GetComponent<Text>();
|
||||
Count = this.transform.Find("Count").GetComponent<Text>();
|
||||
Count = this.transform.Find("CountWrap").Find("Count").GetComponent<Text>();
|
||||
Distance = this.transform.Find("Distance").GetComponent<Text>();
|
||||
TotalClimb = this.transform.Find("TotalClimb").GetComponent<Text>();
|
||||
|
||||
@@ -115,7 +115,6 @@ public class Tips : MonoBehaviour
|
||||
|
||||
m3DIcon.SetActive(_model.Enable3D);
|
||||
|
||||
|
||||
//altitudeGraph
|
||||
|
||||
Utils.DisplayImage(StartCoroutine, altitudeGraph, _model.AltitudeGraph);
|
||||
@@ -129,31 +128,52 @@ public class Tips : MonoBehaviour
|
||||
//{
|
||||
// position.y = position.z;
|
||||
//}
|
||||
this.transform.position = position;
|
||||
|
||||
var localPosition = this.transform.localPosition;
|
||||
if (localPosition.y + 150 > localPosition.z)
|
||||
{
|
||||
localPosition.y = localPosition.z -150;
|
||||
}
|
||||
if(localPosition.x * -1f > localPosition.z)
|
||||
{
|
||||
localPosition.x = localPosition.z * -1f;
|
||||
}
|
||||
else if(localPosition.x > localPosition.z *2)
|
||||
{
|
||||
localPosition.x = localPosition.z * 2;
|
||||
}
|
||||
this.transform.localPosition = localPosition;
|
||||
this.transform.localScale = new Vector2(2, 2);
|
||||
this.Move(position);
|
||||
|
||||
//tips.Show();
|
||||
this.gameObject.SetActive(true);
|
||||
|
||||
this.SetModel(model);
|
||||
}
|
||||
|
||||
public void Move(Vector3 position)
|
||||
{
|
||||
this.transform.position = position;
|
||||
|
||||
var localPosition = this.transform.localPosition;
|
||||
Debug.Log(localPosition.y);
|
||||
if(localPosition.y > 128)
|
||||
{
|
||||
localPosition.y = 128;
|
||||
}
|
||||
if(localPosition.x < -465)
|
||||
{
|
||||
localPosition.x = -465f;
|
||||
}
|
||||
if(localPosition.x > 1080)
|
||||
{
|
||||
localPosition.x = 1080;
|
||||
}
|
||||
//if (localPosition.y + 150 > localPosition.z)
|
||||
//{
|
||||
// localPosition.y = localPosition.z -150;
|
||||
//}
|
||||
//if(localPosition.x * -1f > localPosition.z)
|
||||
//{
|
||||
// localPosition.x = localPosition.z * -1f;
|
||||
//}
|
||||
//else if(localPosition.x > localPosition.z *2)
|
||||
//{
|
||||
// localPosition.x = localPosition.z * 2;
|
||||
//}
|
||||
this.transform.localPosition = localPosition;
|
||||
this.transform.localScale = new Vector2(2, 2);
|
||||
|
||||
Debug.Log($"{ this.transform.localPosition.y }, { this.transform.localPosition.y }");
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
//this.gameObject.SetActive(false);
|
||||
DestroyImmediate(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Confirm : PFUIPanel
|
||||
{
|
||||
private PFUIText _title;
|
||||
private PFUIText _content;
|
||||
private PfUIButton _ok;
|
||||
private UnityAction _callback;
|
||||
private PfUIButton _cancel;
|
||||
protected override void Awake()
|
||||
{
|
||||
//var rect = this.gameObject.AddComponent<RectTransform>();
|
||||
//var layout = this.gameObject.AddComponent<VerticalLayoutGroup>();
|
||||
//layout.spacing = 20f;
|
||||
//layout.childAlignment = TextAnchor.MiddleCenter;
|
||||
|
||||
var wrap = this.transform.Find("GameObject");
|
||||
_title = wrap.Find("Title").GetComponent<PFUIText>();
|
||||
_content = wrap.Find("Content").GetComponent<PFUIText>();
|
||||
//text.transform.SetParent(layout.transform);
|
||||
//text.text = "阿斯达克法拉盛地方";
|
||||
///text = layout.transform.GetChild(0).gameObject.AddComponent<Text>();
|
||||
|
||||
//text = GetComponentInChildren<Transform>().gameObject.AddComponent<Text>();
|
||||
|
||||
_ok = wrap.Find("Ok").GetComponent<PfUIButton>();
|
||||
_cancel = wrap.Find("Cancel").GetComponent<PfUIButton>();
|
||||
//button.onClick.AddListener(() =>
|
||||
//{
|
||||
// this.Close();
|
||||
// //this.Destroy(true);
|
||||
// //DestroyImmediate(this);
|
||||
//});
|
||||
UIManager.AddEvent(_ok.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
if(_callback != null)
|
||||
{
|
||||
_callback();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(_cancel.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Set(string title, string content, UnityAction callback)
|
||||
{
|
||||
//if(text == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//text.text = txt;
|
||||
_title.Text = title;
|
||||
_content.Text = content;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
//bg.alphaHitTestMinimumThreshold
|
||||
|
||||
var color = bg.color;
|
||||
color.a = 0.6f;
|
||||
bg.color = color;
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
|
||||
bg.DOFade(0, 0.2f).OnComplete(() =>
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6618e32f03c775a4b9bf59d1da2a8d24
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -35,7 +35,9 @@ public class MainNav : MonoBehaviour
|
||||
|
||||
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Application.Quit();
|
||||
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
|
||||
Application.Quit();
|
||||
});
|
||||
});
|
||||
|
||||
UIManager.AddEvent(transform.Find("Setting").gameObject, EventTriggerType.PointerClick, x =>
|
||||
|
||||
@@ -30,7 +30,23 @@ public class BigMapController : PFUIPanel
|
||||
UnityEngine.Object begin;
|
||||
Sprite end;
|
||||
private Dictionary<int, LineItem> linesCache = new Dictionary<int, LineItem>();
|
||||
Tips tips;
|
||||
UnityEngine.Object tipsObject;
|
||||
private Tips _tips;
|
||||
private Tips tips
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tips == null)
|
||||
{
|
||||
_tips = ((GameObject)Instantiate(tipsObject, canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
|
||||
}
|
||||
return _tips;
|
||||
}
|
||||
set
|
||||
{
|
||||
_tips = value;
|
||||
}
|
||||
}
|
||||
int timer = 0;
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -76,8 +92,9 @@ public class BigMapController : PFUIPanel
|
||||
var searchBtn = input.Find("Search").gameObject;
|
||||
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
|
||||
|
||||
tips = ((GameObject)Instantiate(Resources.Load("UI/Prefab/BigMap/Tips"), canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
|
||||
tips.Hide();
|
||||
tipsObject = Resources.Load("UI/Prefab/BigMap/Tips");
|
||||
//tips = ((GameObject)Instantiate(tipsObject, canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
|
||||
//tips.Hide();
|
||||
|
||||
BindHeadImage();
|
||||
}
|
||||
@@ -228,6 +245,7 @@ public class BigMapController : PFUIPanel
|
||||
if(item.Value.Selected)
|
||||
{
|
||||
tips.Hide();
|
||||
tips = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,11 +307,16 @@ public class BigMapController : PFUIPanel
|
||||
line.Item = iii;
|
||||
iii.onClick = () =>
|
||||
{
|
||||
if(tips != null)
|
||||
{
|
||||
tips.Hide();
|
||||
tips = null;
|
||||
}
|
||||
if (line.Selected)
|
||||
{
|
||||
line.Selected = false;
|
||||
tips.Hide();
|
||||
//iii.Selected(false);
|
||||
//tips.Hide();
|
||||
//tips = null;
|
||||
return;
|
||||
}
|
||||
line.Selected = true;
|
||||
@@ -360,7 +383,8 @@ public class BigMapController : PFUIPanel
|
||||
line.Selected = true;
|
||||
var position = line.BeginMarker.transform.position;
|
||||
//position.z += 25;
|
||||
tips.Show(position, line.Model);
|
||||
//tips.Show(position, line.Model);
|
||||
tips.Move(position);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -57,10 +58,11 @@ public class HomeController : PFUIPanel
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
userInfo.Find("BtnMore").GetComponent<PfUIButton>().SetEnabled(false);
|
||||
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowAlert("test");
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
GetSummary();
|
||||
}
|
||||
@@ -156,7 +158,6 @@ public class HomeController : PFUIPanel
|
||||
cg.alpha = 0;
|
||||
base.Show();
|
||||
|
||||
cg.DOFade(1f, 0.3f);
|
||||
|
||||
cg.DOFade(1f, 0.3f);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user