上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

147 lines
4.8 KiB

using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class RouteMapMenuPanel : UIView
{
public Toggle UnitLocToggle;
public Toggle XQZDLocToggle;
public Toggle ZYZDLocToggle;
public Toggle XQZDLineToggle;
public Toggle ZYZDLineToggle;
//上传按钮
public Button UploadButton;
//保存按钮
public Button SaveButton;
//清空按钮
public Button ClearButton;
//上传图片
public AnnotationOpenImage OpenImageFile;
public override void Awake()
{
base.Awake();
//单位位置
UnitLocToggle.OnValueChangedAsObservable()
.Where(_ => DriveRoute.Instance != null)
.Subscribe(value =>
{
DriveRoute.Instance.isCreate = value;
if (value)
{
DriveRoute.Instance.Original = "Company";
DriveRoute.Instance.SourceMode = CreationMode.Single;
}
else
{
DriveRoute.Instance.Original = string.Empty;
DriveRoute.Instance.SourceMode = CreationMode.None;
}
});
//辖区中队位置
XQZDLocToggle.OnValueChangedAsObservable()
.Where(_ => DriveRoute.Instance != null)
.Subscribe(value =>
{
DriveRoute.Instance.isCreate = value;
if (value)
{
DriveRoute.Instance.Original = "XQZD";
DriveRoute.Instance.SourceMode = CreationMode.Single;
}
else
{
DriveRoute.Instance.Original = string.Empty;
DriveRoute.Instance.SourceMode = CreationMode.None;
}
});
//增援中队位置
ZYZDLocToggle.OnValueChangedAsObservable()
.Where(_ => DriveRoute.Instance != null)
.Subscribe(value =>
{
DriveRoute.Instance.isCreate = value;
if (value)
{
DriveRoute.Instance.Original = "ZYZD";
DriveRoute.Instance.SourceMode = CreationMode.Single;
}
else
{
DriveRoute.Instance.Original = string.Empty;
DriveRoute.Instance.SourceMode = CreationMode.None;
}
});
//辖区中队路线
XQZDLineToggle.OnValueChangedAsObservable()
.Where(_ => DriveRoute.Instance != null)
.Subscribe(value =>
{
DriveRoute.Instance.isCreate = value;
DriveRoute.Instance.isArrow = !value;
if (value)
{
DriveRoute.Instance.Original = "XQZDLX";
DriveRoute.Instance.SourceMode = CreationMode.Multipoint;
}
else
{
DriveRoute.Instance.Original = string.Empty;
DriveRoute.Instance.SourceMode = CreationMode.None;
}
});
//增援中队路线
ZYZDLineToggle.OnValueChangedAsObservable()
.Where(_ => DriveRoute.Instance != null)
.Subscribe(value =>
{
DriveRoute.Instance.isCreate = value;
DriveRoute.Instance.isArrow = !value;
if (value)
{
DriveRoute.Instance.Original = "ZYZDLX";
DriveRoute.Instance.SourceMode = CreationMode.Multipoint;
}
else
{
DriveRoute.Instance.Original = string.Empty;
DriveRoute.Instance.SourceMode = CreationMode.None;
}
});
//上传
UploadButton.OnClickAsObservable()
.Subscribe(_ =>
{
UploadButton.GetComponent<AnnotationOpenImage>().Output = DriveRoute.Instance.SourceMap;
});
OpenImageFile.OnLoadTextureFinished = texture =>
{
UploadImage(texture);
};
//保存
SaveButton.OnClickAsObservable()
.Subscribe(_ => DriveRoute.Instance.SaveData());
//清空
ClearButton.OnClickAsObservable()
.Subscribe(_ => DriveRoute.Instance.OnClearData());
}
public override void Hide()
{
base.Hide();
UnitLocToggle.isOn = false;
XQZDLocToggle.isOn = false;
ZYZDLocToggle.isOn = false;
XQZDLineToggle.isOn = false;
ZYZDLineToggle.isOn = false;
}
/// <summary>
/// 上传图片
/// </summary>
public void UploadImage(Texture2D texture)
{
HttpManager.Instance.PostImage($"RouteMap.jpg", texture, a =>
{
DriveRoute.Instance.Data.ImageUrl = a?.ObjectName;
});
}
}