public class ListOnOFFSwitch : MonoBehaviour
{
bool m_bA = true;
bool m_bB = false;
int m_nCount = 0;
List<Info> m_listInfo = new List<Info>();
int m_nPageIndex = 0;
// Use this for initialization
void Start ()
{
m_listInfo.Add(new Info(false, 0));
m_listInfo.Add(new Info(false, 0));
m_listInfo.Add(new Info(false, 0));
}
// Update is called once per frame
void Update ()
{
/// 简单模型
//if (Input.GetKeyDown(KeyCode.W))
//{
// if (m_A)
// {
// m_A = false;
// Debug.Log("A关"+"B开");
// m_B = true;
// }
// else if (m_B)
// {
// m_B = false;
// Debug.Log("A开" + "B关");
// m_A = true;
// }
//}
/// 深入模型
/// 索引赋值
if (Input.GetKeyDown(KeyCode.Q))
{
m_nCount++;
m_listInfo[0] = new Info(true, m_nCount);
Debug.Log("Q "+ m_listInfo[0].m_nIndex);
}
else if (Input.GetKeyDown(KeyCode.W))
{
m_nCount++;
m_listInfo[1] = new Info(true, m_nCount);
Debug.Log("W " + m_listInfo[1].m_nIndex);
}
else if (Input.GetKeyDown(KeyCode.E))
{
m_nCount++;
m_listInfo[2] = new Info(true, m_nCount);
Debug.Log("E " + m_listInfo[2].m_nIndex);
}
/// 对比大小
if (Input.GetKeyDown(KeyCode.K))
{
int max = m_listInfo[0].m_nIndex;
for (int i = 0; i < m_listInfo.Count; i++)
{
if (max < m_listInfo[i].m_nIndex)
{
Debug.Log(": "+ i);
Debug.Log(" 索引: " + i+ "最大值: " +m_listInfo[i].m_nIndex);
max = m_listInfo[i].m_nIndex;
m_nPageIndex = i;
}
}
}
/// 排序 遍历
if (Input.GetKeyDown(KeyCode.B))
{
/// 排序
for (int i = 0; i < m_listInfo.Count; i++)
{
if (i != m_nPageIndex)
{
m_listInfo[i].m_bB = false;
}
}
/// 遍历
for (int i = 0; i < m_listInfo.Count; i++)
{
Debug.Log("索引: " + i + "布尔" + m_listInfo[i].m_bB);
}
}
}
}
class Info
{
public bool m_bB;
public int m_nIndex;
public Info( bool A,int B)
{
m_bB = A;
m_nIndex = B;
}
}
{
bool m_bA = true;
bool m_bB = false;
int m_nCount = 0;
List<Info> m_listInfo = new List<Info>();
int m_nPageIndex = 0;
// Use this for initialization
void Start ()
{
m_listInfo.Add(new Info(false, 0));
m_listInfo.Add(new Info(false, 0));
m_listInfo.Add(new Info(false, 0));
}
// Update is called once per frame
void Update ()
{
/// 简单模型
//if (Input.GetKeyDown(KeyCode.W))
//{
// if (m_A)
// {
// m_A = false;
// Debug.Log("A关"+"B开");
// m_B = true;
// }
// else if (m_B)
// {
// m_B = false;
// Debug.Log("A开" + "B关");
// m_A = true;
// }
//}
/// 深入模型
/// 索引赋值
if (Input.GetKeyDown(KeyCode.Q))
{
m_nCount++;
m_listInfo[0] = new Info(true, m_nCount);
Debug.Log("Q "+ m_listInfo[0].m_nIndex);
}
else if (Input.GetKeyDown(KeyCode.W))
{
m_nCount++;
m_listInfo[1] = new Info(true, m_nCount);
Debug.Log("W " + m_listInfo[1].m_nIndex);
}
else if (Input.GetKeyDown(KeyCode.E))
{
m_nCount++;
m_listInfo[2] = new Info(true, m_nCount);
Debug.Log("E " + m_listInfo[2].m_nIndex);
}
/// 对比大小
if (Input.GetKeyDown(KeyCode.K))
{
int max = m_listInfo[0].m_nIndex;
for (int i = 0; i < m_listInfo.Count; i++)
{
if (max < m_listInfo[i].m_nIndex)
{
Debug.Log(": "+ i);
Debug.Log(" 索引: " + i+ "最大值: " +m_listInfo[i].m_nIndex);
max = m_listInfo[i].m_nIndex;
m_nPageIndex = i;
}
}
}
/// 排序 遍历
if (Input.GetKeyDown(KeyCode.B))
{
/// 排序
for (int i = 0; i < m_listInfo.Count; i++)
{
if (i != m_nPageIndex)
{
m_listInfo[i].m_bB = false;
}
}
/// 遍历
for (int i = 0; i < m_listInfo.Count; i++)
{
Debug.Log("索引: " + i + "布尔" + m_listInfo[i].m_bB);
}
}
}
}
class Info
{
public bool m_bB;
public int m_nIndex;
public Info( bool A,int B)
{
m_bB = A;
m_nIndex = B;
}
}