16 changed files with 787 additions and 18 deletions
@ -0,0 +1,51 @@
|
||||
using AX.MessageSystem; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
public class DeviceFollowTarget : MonoBehaviour |
||||
{ |
||||
public Transform target; |
||||
public Camera uiCamera; |
||||
private float offset_Y = 2.5f; |
||||
|
||||
private void Start() |
||||
{ |
||||
GetComponent<Button>().onClick.AddListener(ViewClick); |
||||
uiCamera = GameObject.Find("Canvas").GetComponent<Canvas>().worldCamera; |
||||
} |
||||
public void ViewClick() |
||||
{ |
||||
MessageDispatcher.SendMessage("FLOORNUMBER", target.GetComponent<DeviceObj>().floorId, "Floor"); |
||||
|
||||
Camera.main.GetComponent<CameraOrbit>().SetCameraView(target.position, 15); |
||||
//if (target) |
||||
//{ |
||||
// target.GetComponent<DeviceObj>().ShowList(); |
||||
//} |
||||
} |
||||
|
||||
private Vector2 WorldPosToUIPos(Vector3 worldPos) |
||||
{ |
||||
Vector2 world2ScreenPos = Camera.main.WorldToScreenPoint(worldPos); |
||||
Vector2 uiPos = new Vector2(); |
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(transform.parent.GetComponent<RectTransform>(), world2ScreenPos, uiCamera, out uiPos); |
||||
return uiPos; |
||||
} |
||||
|
||||
private void LateUpdate() |
||||
{ |
||||
if (gameObject.activeSelf && target) |
||||
{ |
||||
GetComponent<RectTransform>().anchoredPosition = |
||||
WorldPosToUIPos(new Vector3(target.transform.position.x, target.transform.position.y + offset_Y, target.transform.position.z)); |
||||
} |
||||
} |
||||
|
||||
public void SetTarget(DeviceObj deviceObj) |
||||
{ |
||||
target = deviceObj.transform; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0526089f5df3b684ca63d3fcae2ba54f |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,139 @@
|
||||
using Newtonsoft.Json; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
[Serializable] |
||||
public class DeviceCloneData |
||||
{ |
||||
public string name; |
||||
public int floorId; |
||||
public DeviceType type; |
||||
public Vector3 postion; |
||||
} |
||||
public class DeviceObjManager : MonoBehaviour |
||||
{ |
||||
public static DeviceObjManager Instance; |
||||
public GameObject Point; |
||||
public List<DeviceCloneData> NowPointList = new List<DeviceCloneData>(); |
||||
|
||||
private string objId = "objlistid"; |
||||
|
||||
private void Awake() |
||||
{ |
||||
Instance = this; |
||||
} |
||||
private void Start() |
||||
{ |
||||
LoadDeviceObjs(); |
||||
} |
||||
public DeviceObj GetDeviceByName(string dname) |
||||
{ |
||||
DeviceObj result = null; |
||||
foreach (Transform item in transform) |
||||
{ |
||||
if (item.name == dname) |
||||
{ |
||||
result = item.GetComponent<DeviceObj>(); |
||||
break; |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
public void AddObj(string objName) |
||||
{ |
||||
foreach (Transform item in transform) |
||||
{ |
||||
if (item.name == objName && item.GetComponent<DeviceObj>()) |
||||
{ |
||||
var obj = new DeviceCloneData(); |
||||
obj.name = item.name; |
||||
obj.postion = item.position; |
||||
obj.floorId = item.GetComponent<DeviceObj>().floorId; |
||||
obj.type = item.GetComponent<DeviceObj>().BindType; |
||||
bool has = false; |
||||
foreach (var data in NowPointList) |
||||
{ |
||||
if (data.name == obj.name) |
||||
{ |
||||
data.postion = obj.postion; |
||||
data.type = obj.type; |
||||
} |
||||
} |
||||
if (!has) |
||||
{ |
||||
NowPointList.Add(obj); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
SaveObjs(); |
||||
} |
||||
public void DelObj(string objName) |
||||
{ |
||||
foreach (var item in DevicePanelManager.Instance.BindObjectList) |
||||
{ |
||||
if (item.ObjName == objName) |
||||
{ |
||||
item.ObjName = ""; |
||||
break; |
||||
} |
||||
} |
||||
DevicePanelManager.Instance.SaveDeviceObjConfig(); |
||||
for (int i = 0; i < NowPointList.Count; i++) |
||||
{ |
||||
if (NowPointList[i].name == objName) |
||||
{ |
||||
NowPointList.Remove(NowPointList[i]); |
||||
break; |
||||
} |
||||
} |
||||
SaveObjs(); |
||||
} |
||||
public void SaveObjs() |
||||
{ |
||||
var json = JsonConvert.SerializeObject(NowPointList); |
||||
string url = string.Format(HttpManager.Instance.PostBreakPointsById, objId); |
||||
if (Application.platform == RuntimePlatform.WebGLPlayer) |
||||
{ |
||||
url = url.Substring(url.IndexOf("api") - 1); |
||||
} |
||||
HttpManager.Instance.Post(url, json, () => |
||||
{ |
||||
Debug.Log("保存点位成功!"); |
||||
}); |
||||
} |
||||
|
||||
private void LoadDeviceObjs() |
||||
{ |
||||
try |
||||
{ |
||||
string url = string.Format(HttpManager.Instance.GetBreakPointsById, objId); |
||||
Debug.Log($"the url is :{ url}"); |
||||
if (Application.platform == RuntimePlatform.WebGLPlayer) |
||||
{ |
||||
url = url.Substring(url.IndexOf("api") - 1); |
||||
} |
||||
HttpManager.Instance.Get<string>(url, d => |
||||
{ |
||||
NowPointList = JsonConvert.DeserializeObject<List<DeviceCloneData>>(d); |
||||
foreach (Transform item in transform) |
||||
{ |
||||
Destroy(item.gameObject); |
||||
} |
||||
foreach (var item in NowPointList) |
||||
{ |
||||
GameObject go = Instantiate(Point, item.postion, Quaternion.identity, transform); |
||||
go.GetComponent<DeviceObj>().CreateIcon(item.type, item.floorId); |
||||
go.name = item.name; |
||||
SelectionManager.Instance.Sets.Add(go); |
||||
} |
||||
}); |
||||
} |
||||
catch |
||||
{ |
||||
Debug.LogError("暂无数据!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2 |
||||
guid: a574343a24c732d4b85cd8c6f01e2b2a |
||||
MonoImporter: |
||||
externalObjects: {} |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,46 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!1 &7361408201843894546 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 434397035475234364} |
||||
- component: {fileID: 9168469932714213855} |
||||
m_Layer: 5 |
||||
m_Name: DeviceIconPanel |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!224 &434397035475234364 |
||||
RectTransform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 7361408201843894546} |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 0, z: 0} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_RootOrder: 0 |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
m_AnchorMin: {x: 0, y: 0} |
||||
m_AnchorMax: {x: 1, y: 1} |
||||
m_AnchoredPosition: {x: 0, y: 0} |
||||
m_SizeDelta: {x: 0, y: 0} |
||||
m_Pivot: {x: 0.5, y: 0.5} |
||||
--- !u!222 &9168469932714213855 |
||||
CanvasRenderer: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 7361408201843894546} |
||||
m_CullTransparentMesh: 0 |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0ae9d78fde5f1244ba4138d6334966ff |
||||
PrefabImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,135 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!1 &2165570965609724972 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 4024504446923160593} |
||||
- component: {fileID: 3463756388761933415} |
||||
- component: {fileID: 887107569440826126} |
||||
- component: {fileID: 449485609122796019} |
||||
- component: {fileID: -3378482227028537232} |
||||
m_Layer: 5 |
||||
m_Name: Icon |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!224 &4024504446923160593 |
||||
RectTransform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2165570965609724972} |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 0, z: 0} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_RootOrder: 0 |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
m_AnchorMin: {x: 0.5, y: 0.5} |
||||
m_AnchorMax: {x: 0.5, y: 0.5} |
||||
m_AnchoredPosition: {x: 0, y: 0} |
||||
m_SizeDelta: {x: 50, y: 50} |
||||
m_Pivot: {x: 0.5, y: 0.5} |
||||
--- !u!222 &3463756388761933415 |
||||
CanvasRenderer: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2165570965609724972} |
||||
m_CullTransparentMesh: 0 |
||||
--- !u!114 &887107569440826126 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2165570965609724972} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
m_Material: {fileID: 0} |
||||
m_Color: {r: 1, g: 0, b: 0, a: 1} |
||||
m_RaycastTarget: 1 |
||||
m_Maskable: 1 |
||||
m_OnCullStateChanged: |
||||
m_PersistentCalls: |
||||
m_Calls: [] |
||||
m_Sprite: {fileID: 21300000, guid: 5a105fe12e6c52d4db49fa5a196556eb, type: 3} |
||||
m_Type: 0 |
||||
m_PreserveAspect: 0 |
||||
m_FillCenter: 1 |
||||
m_FillMethod: 4 |
||||
m_FillAmount: 1 |
||||
m_FillClockwise: 1 |
||||
m_FillOrigin: 0 |
||||
m_UseSpriteMesh: 0 |
||||
m_PixelsPerUnitMultiplier: 1 |
||||
--- !u!114 &449485609122796019 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2165570965609724972} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: 0526089f5df3b684ca63d3fcae2ba54f, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
target: {fileID: 0} |
||||
uiCamera: {fileID: 0} |
||||
--- !u!114 &-3378482227028537232 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2165570965609724972} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
m_Navigation: |
||||
m_Mode: 3 |
||||
m_SelectOnUp: {fileID: 0} |
||||
m_SelectOnDown: {fileID: 0} |
||||
m_SelectOnLeft: {fileID: 0} |
||||
m_SelectOnRight: {fileID: 0} |
||||
m_Transition: 1 |
||||
m_Colors: |
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1} |
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} |
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} |
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} |
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} |
||||
m_ColorMultiplier: 1 |
||||
m_FadeDuration: 0.1 |
||||
m_SpriteState: |
||||
m_HighlightedSprite: {fileID: 0} |
||||
m_PressedSprite: {fileID: 0} |
||||
m_SelectedSprite: {fileID: 0} |
||||
m_DisabledSprite: {fileID: 0} |
||||
m_AnimationTriggers: |
||||
m_NormalTrigger: Normal |
||||
m_HighlightedTrigger: Highlighted |
||||
m_PressedTrigger: Pressed |
||||
m_SelectedTrigger: Selected |
||||
m_DisabledTrigger: Disabled |
||||
m_Interactable: 1 |
||||
m_TargetGraphic: {fileID: 0} |
||||
m_OnClick: |
||||
m_PersistentCalls: |
||||
m_Calls: [] |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 85a6b279122fde645be21030eae0c2b4 |
||||
PrefabImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,113 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!1 &3051062197270240133 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 219326116222627409} |
||||
- component: {fileID: 6434786178584522032} |
||||
- component: {fileID: 7372847723308216205} |
||||
- component: {fileID: 4951752539651406649} |
||||
- component: {fileID: -3409302782171348623} |
||||
m_Layer: 0 |
||||
m_Name: Point |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!4 &219326116222627409 |
||||
Transform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 3051062197270240133} |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 0, z: 0} |
||||
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_RootOrder: 0 |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
--- !u!33 &6434786178584522032 |
||||
MeshFilter: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 3051062197270240133} |
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
||||
--- !u!23 &7372847723308216205 |
||||
MeshRenderer: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 3051062197270240133} |
||||
m_Enabled: 1 |
||||
m_CastShadows: 1 |
||||
m_ReceiveShadows: 1 |
||||
m_DynamicOccludee: 1 |
||||
m_MotionVectors: 1 |
||||
m_LightProbeUsage: 1 |
||||
m_ReflectionProbeUsage: 1 |
||||
m_RayTracingMode: 2 |
||||
m_RenderingLayerMask: 1 |
||||
m_RendererPriority: 0 |
||||
m_Materials: |
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} |
||||
m_StaticBatchInfo: |
||||
firstSubMesh: 0 |
||||
subMeshCount: 0 |
||||
m_StaticBatchRoot: {fileID: 0} |
||||
m_ProbeAnchor: {fileID: 0} |
||||
m_LightProbeVolumeOverride: {fileID: 0} |
||||
m_ScaleInLightmap: 1 |
||||
m_ReceiveGI: 1 |
||||
m_PreserveUVs: 0 |
||||
m_IgnoreNormalsForChartDetection: 0 |
||||
m_ImportantGI: 0 |
||||
m_StitchLightmapSeams: 1 |
||||
m_SelectedEditorRenderState: 3 |
||||
m_MinimumChartSize: 4 |
||||
m_AutoUVMaxDistance: 0.5 |
||||
m_AutoUVMaxAngle: 89 |
||||
m_LightmapParameters: {fileID: 0} |
||||
m_SortingLayerID: 0 |
||||
m_SortingLayer: 0 |
||||
m_SortingOrder: 0 |
||||
--- !u!65 &4951752539651406649 |
||||
BoxCollider: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 3051062197270240133} |
||||
m_Material: {fileID: 0} |
||||
m_IsTrigger: 0 |
||||
m_Enabled: 1 |
||||
serializedVersion: 2 |
||||
m_Size: {x: 1, y: 1, z: 1} |
||||
m_Center: {x: 0, y: 0, z: 0} |
||||
--- !u!114 &-3409302782171348623 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 3051062197270240133} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: 740b18542139ee9469c8e41c0175ef99, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
BindType: 0 |
||||
tParent: {fileID: 7361408201843894546, guid: 0ae9d78fde5f1244ba4138d6334966ff, type: 3} |
||||
tIcon: {fileID: 2165570965609724972, guid: 85a6b279122fde645be21030eae0c2b4, type: 3} |
||||
tIconObj: {fileID: 0} |
||||
isShow: 0 |
Loading…
Reference in new issue