コード例 #1
0
ファイル: Export.cs プロジェクト: hellenzhang/VoiceVoice
 static void GetTextData(Transform p_parent, OneGround p_ground)
 {
     Text[] t_textArry = p_parent.gameObject.GetComponentsInChildren <Text>();
     if (t_textArry != null)
     {
         for (int j = 0; j < t_textArry.Length; j++)
         {
             Text     t_text = t_textArry[j];
             TextData t_td   = new TextData();
             t_td.m_text       = t_text.text;
             t_td.m_fontSize   = t_text.fontSize;
             t_td.m_textColor  = "#" + ColorUtility.ToHtmlStringRGB(t_text.color);
             t_td.m_leftLength = Math.Round(t_text.rectTransform.anchoredPosition.x, 0);
             t_td.m_upLength   = Math.Round(t_text.rectTransform.anchoredPosition.y, 0);
             p_ground.m_textArry.Add(t_td);
         }
     }
 }
コード例 #2
0
ファイル: Export.cs プロジェクト: hellenzhang/VoiceVoice
    static MapData GetMapData()
    {
        MapData t_data = new MapData();

        OneScene t_scene = new OneScene();

        t_data.all.Add(t_scene);
        GameObject t_g          = GameObject.Find("Edit_Map");
        int        t_floorIndex = 0;
        int        t_roofIndex  = 0;
        //找到地板
        Transform t_floor = GameObject.Find("Floor_Container").transform;

        //设置地板
        Transform[] t_allFloorArry = t_floor.GetComponentsInChildren <Transform>();
        for (int i = 0; i < t_allFloorArry.Length; i++)
        {
            RectTransform t_rectTrans = t_allFloorArry[i] as RectTransform;
            if (t_rectTrans.name.Contains("Data_floor"))
            {
                OneGround t_ground = new OneGround();
                t_ground.m_id         = t_floorIndex++;
                t_ground.groundType   = 0;
                t_ground.m_groundPath = "res/block0.png";
                t_ground.m_posx       = Math.Round(t_rectTrans.localPosition.x, 0);
                t_ground.m_posy       = Math.Round(960 - t_rectTrans.localPosition.y, 0);
                t_ground.m_width      = Math.Round(t_rectTrans.rect.width, 0);
                t_ground.m_height     = Math.Round(t_rectTrans.rect.height, 0);
                //查找文本--
                GetTextData(t_rectTrans, t_ground);
                t_scene.arry.Add(t_ground);
            }
        }
        //设置房顶
        Transform t_roof = GameObject.Find("Roof_Container").transform;

        Transform[] t_allRoofArry = t_roof.GetComponentsInChildren <Transform>();
        for (int i = 0; i < t_allRoofArry.Length; i++)
        {
            RectTransform t_rectTrans = t_allRoofArry[i] as RectTransform;
            if (t_rectTrans.name.Contains("Data_roof"))
            {
                OneGround t_ground = new OneGround();
                t_ground.m_id         = t_floorIndex++;
                t_ground.groundType   = 1;
                t_ground.m_groundPath = "res/block0.png";
                t_ground.m_posx       = Math.Round(t_rectTrans.localPosition.x, 0);
                t_ground.m_posy       = Math.Round(-t_rectTrans.localPosition.y, 0);
                t_ground.m_width      = Math.Round(t_rectTrans.rect.width, 0);
                t_ground.m_height     = Math.Round(t_rectTrans.rect.height, 0);
                GetTextData(t_rectTrans, t_ground);
                t_scene.arry.Add(t_ground);
            }
        }
        //设置火石
        Transform t_fireStone = GameObject.Find("FireStone_Container").transform;

        Transform[] t_allFireStoneArry = t_fireStone.GetComponentsInChildren <Transform>();
        for (int i = 0; i < t_allFireStoneArry.Length; i++)
        {
            RectTransform t_rectTrans = t_allFireStoneArry[i] as RectTransform;
            if (t_rectTrans.name.Contains("Data_fireStone"))
            {
                OneGround t_ground = new OneGround();
                t_ground.m_id         = t_floorIndex++;
                t_ground.groundType   = 2;
                t_ground.m_groundPath = "res/block1.png";
                t_ground.m_posx       = Math.Round(t_rectTrans.localPosition.x, 0);
                t_ground.m_posy       = Math.Round(-t_rectTrans.localPosition.y, 0);
                t_ground.m_width      = Math.Round(t_rectTrans.rect.width, 0);
                t_ground.m_height     = Math.Round(t_rectTrans.rect.height, 0);
                GetTextData(t_rectTrans, t_ground);
                t_scene.arry.Add(t_ground);
            }
        }
        return(t_data);
    }