Ejemplo n.º 1
0
    /// <summary>
    /// 加载路组件
    /// </summary>
    /// <param name="PrefabName"></param>
    /// <returns></returns>
    public static GameObject LoadRoadComponent(string PrefabName)
    {
        int        hash = PrefabName.GetHashCode();
        GameObject obj  = null;

        if (!RoadCache.TryGetValue(hash, out obj))
        {
            obj             = Resources.Load <GameObject>(cfg_RoadComponentPath + PrefabName);
            RoadCache[hash] = obj;
        }
        if (obj == null)
        {
            Debugger.LogError("路组件不存在:" + PrefabName);
            return(null);
        }
        return(GameObject.Instantiate(obj));
    }
 void updateCacheForRoad(int index, TrafficRule rule) {
     if (rule == TrafficRule.Stop) {
         if (m_cacheForRoad.ContainsKey(index)) {
             m_cacheForRoad.Remove(index);
         }
     } else {
         if (!m_cacheForRoad.ContainsKey(index)) {
             RoadCache data = new RoadCache();
             data.position = m_list[index].position;
             data.isUp = (rule & TrafficRule.Up) != 0;
             m_cacheForRoad[index] = data;
         }
     }
 }