48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | ||
| using System.Collections.Generic;
 | ||
| using UnityEngine;
 | ||
| 
 | ||
| public class WireTool : MonoBehaviour
 | ||
| {
 | ||
|     public List<GameObject> StartPoints = new List<GameObject>();
 | ||
|     public List<GameObject> EndPoints = new List<GameObject>();
 | ||
| 
 | ||
|     public bool sagHandle;
 | ||
| 
 | ||
|     [Header("弧垂线路(Format: 1-2A相)")]
 | ||
|     public List<string> sagLine = new List<string>();
 | ||
|     public float sagRatio;
 | ||
|     private void Awake()
 | ||
|     {
 | ||
|         foreach (var item in StartPoints)
 | ||
|         {
 | ||
|             //格式:1-2_A相_Start
 | ||
| 
 | ||
|             var start = item;
 | ||
|             //线路
 | ||
|             string line = item.name.Split('_')[0];
 | ||
|             //位置
 | ||
|             string position = item.name.Split('_')[1];
 | ||
| 
 | ||
|             var end = EndPoints.Find((point) =>
 | ||
|             {
 | ||
|                 return point.name.Split('_')[0].Equals(line) && point.name.Split('_')[1].Equals(position);
 | ||
|             });
 | ||
| 
 | ||
|             string linePosition = line + position;
 | ||
|             if (start != null && end != null)
 | ||
|             {
 | ||
|                 if (sagLine.Contains(linePosition))
 | ||
|                     WireObject.CreateWire(transform, start.transform, end.transform, sagRatio,linePosition);
 | ||
|                 else
 | ||
|                     WireObject.CreateWire(transform, start.transform, end.transform, 0, linePosition);
 | ||
|             }
 | ||
|         }
 | ||
|     }
 | ||
| 
 | ||
|     public void AddSagLine()
 | ||
|     {
 | ||
| 
 | ||
|     }
 | ||
| }
 |