【发布时间】:2015-08-17 16:23:38
【问题描述】:
我想知道如何在另一个脚本中访问字典中的键。可能吗。我有两个脚本,我想知道这是否可能。我已经在字典中添加了键,我想知道如何访问它们。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Vuforia
{
public class ZoneDictonary : MonoBehaviour
{
public Vector3 Zone1V;
public Vector3 Zone2V;
public Vector3 Zone3V;
public Vector3 Zone4V;
public Vector3 Zone5V;
void Start()
{
Dictionary<Vector3, bool> isZoneEmpty = new Dictionary<Vector3, bool> ();
isZoneEmpty.Add (Zone1V, true);
isZoneEmpty.Add (Zone2V, true);
isZoneEmpty.Add (Zone3V, true);
isZoneEmpty.Add (Zone4V, true);
isZoneEmpty.Add (Zone5V, true);
}
}
}
这是另一个脚本。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Vuforia
{
public class Test : MonoBehaviour
{
ZoneDictonary Zd;
void Start()
{
GameObject ZD = GameObject.FindGameObjectWithTag ("Zone Manager");
Zd = ZD.GetComponent<ZoneDictonary> ();
}
}
}
【问题讨论】:
标签: c# c#-4.0 dictionary unity3d unityscript