GoView.Set C# (CSharp) Method

Set() public method

public Set ( DXFStructure dxf ) : void
dxf DXFConvert.DXFStructure
return void
    public void Set(DXFStructure dxf)
    {
        //先初始化图层
        foreach (TABLE table in dxf.TABLES.TABLEList)
        {
            if (table.LAYERList.Count == 0) continue;

            foreach (LAYER item in table.LAYERList)
            {
                GameObject go = Instantiate(Layer) as GameObject;
                go.transform.parent = gameObject.transform;
                var l = go.GetComponent<GoLayer>();
                l.Set(item);

                if (item.C2 != null)
                    Layers.Add(item.C2, l);
            }
        }

        //构建一个默认图层,没有图层属性的对象放在此图层
        GameObject goDefaultLayer = Instantiate(Layer) as GameObject;
        GoLayer.DefaultLayer = goDefaultLayer.GetComponent<GoLayer>();
        GoLayer.DefaultLayer.ZoomAdjust = 0.8f;

        //绘制各图层下的元素
        foreach (var item in Layers)
        {
            item.Value.Load(dxf);
        }

        //初始化相机位置
        //camera.transform.position = new Vector3((MaxX + MinX) / 2, (MaxY + MinY) / 2, -10);

        this.transform.position = new Vector3(this.transform.position.x - (MaxX + MinX) / 2,
          this.transform.position.y - (MaxY + MinY) / 2,
            0);

        camera.orthographicSize = ((MaxX - MinX) + (MaxY - MinY)) / 20;

        Zoom = (camera.orthographicSize / 250);

        //初始化优化代码
        ResizeObjects.ForEach((l) =>
        {
            l.ToMin();
            if (l.gameObject.activeSelf)
                l.SetSetWidth();
        });
    }

Usage Example

コード例 #1
0
 private void LoadDXF(string path)
 {
     try
     {
         DiskFile iLoader = new DiskFile(path);
         DXFConvert.DXFStructure dxfStructure = new DXFConvert.DXFStructure(iLoader);
         dxfStructure.Load();
         iLoader.Dispose();
         GoView.Set(dxfStructure);
         Debug.Log("OK:" + path);
     }
     catch (System.Exception ex)
     {
         Debug.Log("Error:" + path);
         Debug.LogError(ex.ToString());
     }
 }