private void CreateTrainsByData()
    {
        DebugLog("CreateTrainsByData() start.");

        DestroyTrainDisplayObjects();


        foreach (TrainData td in m_TrainData.Values)
        {
            bool skip = false;

            DebugLog("m_DisplayEditorMode=" + m_DisplayEditorMode.ToString());
            DebugLog("m_RecreateTrainKeyword=" + m_RecreateTrainKeyword);

            // 圖示
            string textureName = "";
            if (true == m_TrainTypeTextureMap.ContainsKey(td.TypeStr))
            {
                textureName = m_TrainTypeTextureMap[td.TypeStr];
            }

            Texture2D trainTexture = (Texture2D)Resources.Load(textureName,
                                                               typeof(Texture2D));
            if (null == trainTexture)
            {
                Debug.LogError("CreateTrainsByData() trainTexture load failed=" + textureName);
                return;
            }

            switch (m_DisplayEditorMode)
            {
            case DisplayEditorMode.NearStation:
                int stationid_i = 0;
                int stationid_j = 0;

                if (true == FindTrainBetween(td,
                                             ref stationid_i,
                                             ref stationid_j))
                {
                    Dictionary <int, StationData> stationDataVec = m_Stations;

                    DebugLog("i ].DisplayName" + stationDataVec[stationid_i].DisplayName);
                    DebugLog("j ].DisplayName" + stationDataVec[stationid_j].DisplayName);

                    if (m_RecreateTrainKeyword != stationDataVec[stationid_i].DisplayName &&
                        m_RecreateTrainKeyword != stationDataVec[stationid_j].DisplayName)
                    {
                        skip = true;
                    }
                }
                break;

            case DisplayEditorMode.SpecifiedTrain:
                if (td.DisplayName != m_RecreateTrainKeyword)
                {
                    skip = true;
                }
                break;

            case DisplayEditorMode.AllTrains:
                // do nothing , all pass.
                break;

            case DisplayEditorMode.NoTrain:
                return;                 // do nothing at all
            }
            if (true == skip)
            {
                continue;
            }


            string objName = "Train_" + td.DisplayName + "(" + td.ID + ")";
            DebugLog("CreateTrainsByData() ." + td.ID);
            GameObject trainObj = new GameObject(objName);

            float trainSize = 32.0f;

            GUITexture guiTexture = trainObj.AddComponent <GUITexture>();
            if (null != guiTexture)
            {
                trainObj.transform.position   = new Vector3(0, 0, m_TrainLayerZShift);
                trainObj.transform.localScale = new Vector3(0, 0, 1);
                guiTexture.texture            = trainTexture;
                guiTexture.pixelInset         = new Rect(-1 * trainSize / 2,
                                                         -1 * trainSize / 2,
                                                         trainSize,
                                                         trainSize);
            }

            GameObject textObj = new GameObject(objName + "_Text");
            GUIText    guiText = textObj.AddComponent <GUIText>();
            if (null != guiText)
            {
                guiText.fontSize       = 24;
                guiText.material.color = Color.white;
                guiText.text           = td.DisplayName;
                guiText.pixelOffset    = new Vector2(
                    1 * trainSize / 2,
                    0);
            }
            textObj.transform.parent        = trainObj.transform;
            textObj.transform.localPosition = new Vector3(0, 0, m_TrainLayerZShift + 1);


            TrainDisplay tDisplay = new TrainDisplay();
            tDisplay.ID  = td.ID;
            tDisplay.Obj = trainObj;

            m_TrainDisplay.Add(tDisplay.ID, tDisplay);
        }

        DebugLog("CreateTrainsByData() ended.");
    }
    private void CreateTrainsByData()
    {
        Debug.Log("CreateTrainsByData() start.");

        DestroyTrainDisplayObjects();

        Object prefab = Resources.Load("TrainPrefab");

        if (null == prefab)
        {
            Debug.LogError("CreateTrainsByData() CubePrefab load failed=");
            return;
        }
        Object textMeshPrefab = Resources.Load("TextMeshPrefab");

        if (null == textMeshPrefab)
        {
            Debug.LogError("CreateTrainsByData() textMeshPrefab load failed");
            return;
        }

        if (null != this.pCameraControl &&
            m_DisplayEditorMode != DisplayEditorMode.SpecifiedTrain)
        {
            this.pCameraControl.trackingObject = null;
        }


        foreach (TrainData td in m_TrainData.Values)
        {
            bool skip = false;

            Debug.Log("m_DisplayEditorMode=" + m_DisplayEditorMode.ToString());
            Debug.Log("m_RecreateTrainKeyword=" + m_RecreateTrainKeyword);



            Dictionary <int, StationData> stationDataVec = m_Stations;
            switch (m_DisplayEditorMode)
            {
            case DisplayEditorMode.NearStation:

                int stationid_i = 0;
                int stationid_j = 0;

                if (true == FindTrainBetween(td,
                                             ref stationid_i,
                                             ref stationid_j))
                {
                    // Debug.Log( "i ].DisplayName" + stationDataVec[ stationid_i ].DisplayName ) ;
                    // Debug.Log( "j ].DisplayName" + stationDataVec[ stationid_j ].DisplayName ) ;
                    if (m_RecreateTrainKeyword != stationDataVec[stationid_i].DisplayName &&
                        m_RecreateTrainKeyword != stationDataVec[stationid_j].DisplayName)
                    {
                        skip = true;
                    }
                }
                break;

            case DisplayEditorMode.SpecifiedTrain:
                if (td.DisplayName != m_RecreateTrainKeyword)
                {
                    skip = true;
                }
                break;

            case DisplayEditorMode.AllTrains:
                // do nothing , all pass.
                break;

            case DisplayEditorMode.NoTrain:
                return;                 // do nothing at all
            }

            if (true == skip)
            {
                continue;
            }

            // 圖示
            string textureName = "";
            if (true == m_TrainTypeTextureMap.ContainsKey(td.TypeStr))
            {
                textureName = m_TrainTypeTextureMap[td.TypeStr];
            }

            Texture2D trainTexture = (Texture2D)Resources.Load(textureName,
                                                               typeof(Texture2D));
            if (null == trainTexture)
            {
                Debug.LogError("CreateTrainsByData() trainTexture load failed=" + textureName);
                continue;
            }

            string objName = "Train_" + td.DisplayName + "(" + td.ID + ")";
            Debug.Log("CreateTrainsByData() ." + objName);
            GameObject trainObj = (GameObject)GameObject.Instantiate(prefab);
            trainObj.name = objName;

            Renderer renderer = trainObj.GetComponent <Renderer>();
            if (null != renderer)
            {
                trainObj.transform.position   = new Vector3(0, 0, m_TrainLayerZShift);
                renderer.material             = new Material(Shader.Find(" Diffuse"));
                renderer.material.mainTexture = trainTexture;
            }

            GameObject textObj = (GameObject)GameObject.Instantiate(textMeshPrefab);
            textObj.name = objName + "_Text";
            TextMesh textMesh = textObj.GetComponent <TextMesh>();
            if (null != textMesh)
            {
                textMesh.text = td.DisplayName;
            }
            textObj.transform.parent        = trainObj.transform;
            textObj.transform.localPosition = Vector3.zero;
            textObj.transform.localScale    = new Vector3(-0.5f, -0.5f, 1);

            TrainDisplay tDisplay = new TrainDisplay();
            tDisplay.ID  = td.ID;
            tDisplay.Obj = trainObj;


            m_TrainDisplay.Add(tDisplay.ID, tDisplay);

            if (null != this.pCameraControl &&
                m_DisplayEditorMode == DisplayEditorMode.SpecifiedTrain)
            {
                Debug.Log("td.ID ");
                this.pCameraControl.trackingObject =
                    tDisplay.Obj;
            }
        }

        Debug.Log("CreateTrainsByData() ended.");
    }