165 lines
3.9 KiB
C#
165 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/// <summary>
|
|
/// 端口线条信息(端子信息)
|
|
/// </summary>
|
|
[Serializable]
|
|
public class LineInfor : MonoBehaviour
|
|
{
|
|
//InputField t;
|
|
[HideInInspector] public Root root;
|
|
|
|
public List<Transform> lines = new List<Transform>();
|
|
public string cableGroupName = "";
|
|
public string cableName = "";
|
|
public string portType = "";
|
|
|
|
LineRenderer lineRenderer;
|
|
|
|
public Material material;
|
|
public Material material_clon;
|
|
|
|
public Color newColor;
|
|
|
|
public Color albedoColor;
|
|
public Color emissionColor;
|
|
|
|
private void Awake()
|
|
{
|
|
|
|
lineRenderer = GetComponent<LineRenderer>();
|
|
material = lineRenderer.materials[0];
|
|
material_clon = GameObject.Instantiate<Material>(Resources.Load<Material>("emission"));
|
|
|
|
lineRenderer.materials[0] = material_clon;
|
|
//// 获取材质球组件
|
|
////material = GetComponent<Material>().materials[0];
|
|
|
|
//// 获取Albedo颜色
|
|
//albedoColor = material.GetColor("_Color");
|
|
|
|
//// 获取Emission颜色
|
|
//emissionColor = material.GetColor("_EmissionColor");
|
|
|
|
//// 设置Albedo颜色
|
|
//material.SetColor("_Color", newColor);
|
|
|
|
//// 设置Emission颜色
|
|
//material.SetColor("_EmissionColor", newColor);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
//Debug.Log("版本号 1.1.1");
|
|
setcolor();
|
|
//Debug.Log("版本号 1.1.1");
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
//if (portType == "电缆线")
|
|
//{
|
|
// run_line();
|
|
//}
|
|
|
|
if (GameManager.Inst.magnifyState)
|
|
{
|
|
if (lineRenderer.startWidth == lineWidth_min)
|
|
return;
|
|
setLineWidth(lineWidth_min);
|
|
}
|
|
else
|
|
{
|
|
if (lineRenderer.startWidth == lineWidth_max)
|
|
return;
|
|
setLineWidth(lineWidth_max);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void run_line()
|
|
{
|
|
|
|
}
|
|
|
|
[ContextMenu("查看PlayerPrefs")]
|
|
void PrintAllPlayerPrefs()
|
|
{
|
|
// 获取PlayerPrefs中所有的键
|
|
string[] keys = GetAllPlayerPrefsKeys();
|
|
|
|
// 遍历所有的键
|
|
foreach (string key in keys)
|
|
{
|
|
string value = PlayerPrefs.GetString(key);
|
|
Debug.Log("Key: " + key + ", Value: " + value);
|
|
}
|
|
}
|
|
// 获取PlayerPrefs中所有的键
|
|
private string[] GetAllPlayerPrefsKeys()
|
|
{
|
|
int count = PlayerPrefs.GetInt("PlayerPrefsCount");
|
|
string[] keys = new string[count];
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
keys[i] = PlayerPrefs.GetString("PlayerPrefsKey" + i.ToString());
|
|
}
|
|
|
|
return keys;
|
|
}
|
|
|
|
|
|
public float lineWidth_min = 0.01f;
|
|
public float lineWidth_max = 0.03f;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 设置LineRenderer宽度
|
|
/// </summary>
|
|
/// <param name="lineWidth"></param>
|
|
[ContextMenu("设置LineRenderer宽度")]
|
|
public void setLineWidth(float lineWidth)
|
|
{
|
|
lineRenderer.startWidth = lineWidth;
|
|
lineRenderer.endWidth = lineWidth;
|
|
}
|
|
|
|
public void setcolor()
|
|
{
|
|
// 设置Albedo颜色
|
|
//material.SetColor("_Color", newColor);
|
|
material.SetColor("_Color", Color.white);
|
|
|
|
// 设置Emission颜色
|
|
material.EnableKeyword("_EMISSION");// 启用发光
|
|
material.SetColor("_EmissionColor", newColor);
|
|
}
|
|
|
|
public void setcolor(Color color)
|
|
{
|
|
// 设置Albedo颜色
|
|
//material.SetColor("_Color", color);
|
|
material.SetColor("_Color", Color.white);
|
|
|
|
// 设置Emission颜色
|
|
material.EnableKeyword("_EMISSION");// 启用发光
|
|
material.SetColor("_EmissionColor", color);
|
|
}
|
|
|
|
#region JSON
|
|
[System.Serializable]
|
|
public class Root
|
|
{
|
|
[Header("自己ID")] public string myID;
|
|
|
|
[Header("对方ID")] public string otherID;
|
|
|
|
[Header("线条UID")] public string lineUID;
|
|
}
|
|
#endregion
|
|
}
|