예제 #1
0
    void ExportCreation()
    {
        if (VCEditor.s_Scene == null || VCEditor.s_Scene.m_IsoData == null)
        {
            Debug.Log("VCEditor IsoData is null!");
            return;
        }

        new_creation              = new CreationData();
        new_creation.m_ObjectID   = CreationMgr.QueryNewId();
        new_creation.m_RandomSeed = UnityEngine.Random.value;
        new_creation.m_Resource   = VCEditor.s_Scene.m_IsoData.Export();
        new_creation.ReadRes();

        new_creation.GenCreationAttr();         // 计算属性

        if (new_creation.SaveRes())
        {
            new_creation.BuildPrefab();
            new_creation.Register();
            CreationMgr.AddCreation(new_creation);
        }
        else
        {
            Debug.Log("Save creation resource file failed !");
            new_creation.Destroy();
            return;
        }

        GameObject obj = CreationMgr.InstantiateCreation(new_creation.m_ObjectID, 0, true, null);

        if (obj != null)
        {
            if (new_creation.m_Attribute.m_Type == ECreation.Vehicle)
            {
                obj.transform.localPosition = ExportPosVehicle.position;
            }
            if (new_creation.m_Attribute.m_Type == ECreation.Aircraft)
            {
                obj.transform.localPosition = ExportPosAircraft.position;
            }
            if (new_creation.m_Attribute.m_Type == ECreation.Boat)
            {
                obj.transform.localPosition = ExportPosBoat.position;
            }

            ZXCameraCtrl ZXCamera = mMainCamera.GetComponent <ZXCameraCtrl>();
            ZXCamera.Following = obj.transform;
        }
        creation_obj = obj;
    }