コード例 #1
0
    /// <summary>
    /// 加载简化模型,在该脚本被加载时
    /// </summary>
    /// <param name="index"></param>
    /// <param name="finished"></param>
    private void LoadSimpleModel(int index, Action finished)
    {
        Debug.Log("LoadModel :" + index);
        SetProgress(index);
        if (index >= modelList.Count)
        {
            TimeSpan time = DateTime.Now - allStart;
            Debug.Log("LoadModel Finished time:" + time);
            Debug.Log(LoadLog);
            if (finished != null)
            {
                finished();
            }
            return;
        }
        var      item       = modelList[index];
        DateTime start      = DateTime.Now;
        var      bundleName = GetFullBundleName(item.GetSimpleBundleName());

        ChunkManager.LoadBundle(bundleName, item.assetName, obj =>
        {
            Debug.Log("LoadBundle :" + obj);
            if (obj != null)
            {
                item.isLoaded = true;
                var parent    = transform.FindChildByName(item.parentName);
                var instance  = GameObject.Instantiate(obj, parent);
                instance.name = obj.name;

                DeviceModelInfo info = instance.AddComponent <DeviceModelInfo>();
                info.ModelInfo       = item;
                //if (item.isSimple == false)
                //{
                //    info.IsLoaded = true;//有些设备不是简化模型,直接就是原模型,不需要再加载精细模型
                //}
            }
            else
            {
            }

            TimeSpan time = DateTime.Now - start;
            string log    = string.Format("{0}:{1}", index, time);
            LoadLog      += log += "\n";
            LoadSimpleModel(index + 1, finished);
        });
    }
コード例 #2
0
    private bool IsInViewEx(DeviceModelInfo item)
    {
        if (item == null)
        {
            return(false);
        }

        bool inView = false;
        var  points = item.GetTestPoints();

        foreach (var point in points)
        {
            var r = IsInView(point, Camera.main, minView, maxView);
            if (r)
            {
                inView = true;
                break;
            }
        }
        return(inView);
    }
コード例 #3
0
 private void UnLoadDevicesWhenNotInDistance()
 {
     for (int i = 0; i < LoadedDevices.Count; i++)
     {
         try
         {
             DeviceModelInfo item = LoadedDevices[i];
             if (!item.IsInDistance(subject, isRoam))
             {
                 item.UnloadAsset();
                 LoadedDevices.RemoveAt(i);
                 i--;
                 ShowVertexs();
             }
         }
         catch (Exception ex)
         {
             Debug.LogError("SceneAssetManager.UnLoadDevicesWhenNotInDistance:" + ex);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// 详情页数据
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public ActionResult GetListFormJson(string keyValue)
        {
            var             list = _deviceBrandManager.GetAllByBrandKeys();
            DeviceModelInfo data = null;
            var             flag = keyValue.Substring(0, 1);

            int.TryParse(keyValue.Substring(1), out int pkid);
            switch (flag)
            {
            case "B":
                data = list.FirstOrDefault(m => m.BrandID == pkid);
                break;

            case "T":
                data = list.FirstOrDefault(m => m.TypeID == pkid);
                break;

            case "M":
                data = list.FirstOrDefault(m => m.ModelID == pkid);
                break;
            }
            return(Content(JsonConvert.SerializeObject(data)));
        }