TankInitSystem InitTankPrefabs()
    {
        #region Collision Detect
        if (vehicleData.modelData.MainModel.GetComponentsInChildren <BoxCollider>().Length == 0)
        {
            if (EditorUtility.DisplayDialog("Error", "Collision should be set.We will redirct you to it.", "OK,l will set it now!", "No,l will choose another one"))
            {
                EditorGUIUtility.PingObject(vehicleData.modelData.MainModel.GetInstanceID());
                OpenEditorScene();

                GameObject EditColliderInstance = Instantiate <GameObject>(vehicleData.modelData.MainModel);
                EditColliderInstance.name = vehicleData.modelData.MainModel.name;

                string TempPath       = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(vehicleData.modelData.MainModel.GetInstanceID()));
                string PrefabStoreDir = System.IO.Directory.CreateDirectory(string.Format(TempPath + "/Collisions_{0}", vehicleData.modelData.MainModel.name)).FullName;

                AssetDatabase.Refresh();
                return(null);
                //PrefabUtility.CreatePrefab (string.Format (PrefabStoreDir + "/{0}.prefab", vehicleData.modelData.MainModel.name),EditColliderInstance);
            }
            else
            {
                return(null);
            }
        }
        #endregion
        GameObject TankPrefabs  = new GameObject();
        GameObject InstanceMesh = Instantiate(vehicleData.modelData.MainModel);

        try {
            #region Init
            InstanceMesh.name = vehicleData.modelData.MainModel.name;
            #endregion

            TankPrefabs.name = InstanceMesh.name + "_Pre";

            InstanceMesh.transform.parent = TankPrefabs.transform;

            GameObject TankTransform = new GameObject("TankTransform");
            TankTransform.transform.parent = InstanceMesh.transform;

            Transform RightWheel, LeftWheel, RightUpperWheels, LeftUpperWheels, Turret, Gun, GunDym;
            #region Find Dumps
            RightWheel = InstanceMesh.transform.Find("RightWheel");
            LeftWheel  = InstanceMesh.transform.Find("LeftWheel");
            Turret     = InstanceMesh.transform.Find("Turret");
            Gun        = Turret.transform.Find("Gun");
            GunDym     = Gun.GetChild(0);


            RightUpperWheels = InstanceMesh.transform.Find("RightUpperWheel");
            LeftUpperWheels  = InstanceMesh.transform.Find("LeftUpperWheel");
            #endregion
            RightWheel.parent       = TankTransform.transform;
            LeftWheel.parent        = TankTransform.transform;
            LeftUpperWheels.parent  = TankTransform.transform;
            RightUpperWheels.parent = TankTransform.transform;


            GameObject TurretTransform = new GameObject("TurretTransform");
            GameObject GunTransform    = new GameObject("GunTransform");
            GameObject GunDymTransform = new GameObject("GunDym");

            VehicleComponentsReferenceManager referenceManager = InstanceMesh.AddComponent <VehicleComponentsReferenceManager>();

            TurretTransform.transform.SetParent(InstanceMesh.transform);
            TurretTransform.transform.position = Turret.transform.position;

            GunTransform.transform.position = Gun.transform.position;
            Turret.parent = TurretTransform.transform;

            Gun.parent = GunTransform.transform;
            GunTransform.transform.SetParent(TurretTransform.transform);

            GunDymTransform.transform.position = GunDym.transform.position;
            GunDymTransform.transform.SetParent(GunTransform.transform);
            GunDym.SetParent(GunDymTransform.transform);

            #region Add fire animation
            Animator FireAnimator = GunDymTransform.AddComponent <Animator>();
            FireAnimator.runtimeAnimatorController = vehicleData.vehicleTextData.TFParameter.GymAnimation;
            #endregion

            AddDumpNode("FFPoint", GunTransform.transform, true, referenceManager);
            AddDumpNode("EffectStart", GunTransform.transform, true, referenceManager);
            AddDumpNode("FireForceFeedbackPoint", GunTransform.transform, true, referenceManager);
            AddDumpNode("EngineSmoke", InstanceMesh.transform, true, referenceManager);
            AddDumpNode("EngineSound", InstanceMesh.transform, true, referenceManager);
            AddDumpNode("MainCameraFollowTarget", InstanceMesh.transform, true, referenceManager);
            AddDumpNode("MainCameraGunner", GunTransform.transform, true, referenceManager);
            AddDumpNode("MachineGunFFPoint", TurretTransform.transform, true, referenceManager);
            AddDumpNode("CenterOfGravity", InstanceMesh.transform, true, referenceManager);

            referenceManager.LeftTrack  = InstanceMesh.transform.Find("LeftTrack").gameObject;
            referenceManager.RightTrack = InstanceMesh.transform.Find("RightTrack").gameObject;

            GameObject HitBoxInstance = Instantiate <GameObject>(vehicleData.modelData.HitBox.HitBoxPrefab);
            HitBoxInstance.transform.Find("Main").name = "MainHitBox";
            HitBoxInstance.transform.Find("MainHitBox").SetParent(InstanceMesh.transform);

            HitBoxInstance.transform.Find("Turret").name = "TurretHitBox";
            HitBoxInstance.transform.Find("TurretHitBox").SetParent(TurretTransform.transform);

            HitBoxInstance.transform.Find("Gun").name = "GunHitBox";
            HitBoxInstance.transform.Find("GunHitBox").SetParent(GunTransform.transform);

            HitBoxInstance.transform.Find("Dym").name = "DymHitBox";
            HitBoxInstance.transform.Find("DymHitBox").SetParent(GunDymTransform.transform);

            DestroyImmediate(HitBoxInstance);
            Restore(LeftWheel.GetComponentsInChildren <Transform>());
            Restore(RightWheel.GetComponentsInChildren <Transform>());

            Restore(LeftUpperWheels.GetComponentsInChildren <Transform>());
            Restore(RightUpperWheels.GetComponentsInChildren <Transform>());

            new GameObject("MainCameraTarget").transform.SetParent(TurretTransform.transform);

            TankInitSystem initySystem = TankPrefabs.AddComponent <TankInitSystem>();
            initySystem.PSParameter  = vehicleData.vehicleTextData.PSParameter;
            initySystem.TFParameter  = vehicleData.vehicleTextData.TFParameter;
            initySystem.MTParameter  = vehicleData.vehicleTextData.MTParameter;
            initySystem.PTCParameter = vehicleData.vehicleTextData.PTCParameter;

            return(initySystem);
        }
        catch (System.Exception exception) {
            EditorUtility.DisplayDialog("Exception", exception.Message + "\n" + exception.StackTrace, "OK");
            DestroyImmediate(TankPrefabs);
            throw exception;
            return(null);
        }
    }
    TankInitSystem InitTankPrefabs()
    {
        #region 碰撞检测
        if (vehicleData.modelData.MainModel.GetComponentsInChildren <BoxCollider> ().Length == 0)
        {
            if (EditorUtility.DisplayDialog("错误", "坦克模型必须设置完毕碰撞数据", "好的,立刻去设置", "重新选择资源"))
            {
                EditorGUIUtility.PingObject(vehicleData.modelData.MainModel.GetInstanceID());
                OpenEditorScene();

                GameObject EditColliderInstance = Instantiate <GameObject> (vehicleData.modelData.MainModel);
                EditColliderInstance.name = vehicleData.modelData.MainModel.name;

                string TempPath       = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(vehicleData.modelData.MainModel.GetInstanceID()));
                string PrefabStoreDir = System.IO.Directory.CreateDirectory(string.Format(TempPath + "/Collisions_{0}", vehicleData.modelData.MainModel.name)).FullName;

                AssetDatabase.Refresh();
                //PrefabUtility.CreatePrefab (string.Format (PrefabStoreDir + "/{0}.prefab", vehicleData.modelData.MainModel.name),EditColliderInstance);
            }
            else
            {
                return(null);
            }
        }
        #endregion

        #region 初始化 坦克物体变量
        GameObject TankPrefabs  = new GameObject();
        GameObject InstanceMesh = Instantiate(vehicleData.modelData.MainModel);
        InstanceMesh.name = vehicleData.modelData.MainModel.name;
        #endregion

        TankPrefabs.name = InstanceMesh.name + "_Pre";

        InstanceMesh.transform.parent = TankPrefabs.transform;

        GameObject TankTransform = new GameObject("TankTransform");
        TankTransform.transform.parent = InstanceMesh.transform;

        Transform RightWheel, LeftWheel, RightUpperWheels, LeftUpperWheels, Turret, Gun, GunDym;
        #region 在模型上寻找虚拟对象
        RightWheel = InstanceMesh.transform.Find("RightWheel");
        LeftWheel  = InstanceMesh.transform.Find("LeftWheel");
        Turret     = InstanceMesh.transform.Find("Turret");
        Gun        = Turret.transform.Find("Gun");
        GunDym     = Gun.GetChild(0);

        RightUpperWheels = InstanceMesh.transform.Find("RightUpperWheel");
        LeftUpperWheels  = InstanceMesh.transform.Find("LeftUpperWheel");
        #endregion
        RightWheel.parent       = TankTransform.transform;
        LeftWheel.parent        = TankTransform.transform;
        LeftUpperWheels.parent  = TankTransform.transform;
        RightUpperWheels.parent = TankTransform.transform;

        #region 实例化坦克的附加物体 坦克控制器 坦克脚本 坦克ui 坦克瞄准镜 主摄像机 坦克引擎声音 坦克引擎烟雾 死亡效果
        //EngineSmoke = new GameObject("EngineSmoke");
        //LeftTrackEffect = new GameObject("LeftTrackEffect");
        //RightTrackEffect=new GameObject("RightTrackEffect");
        #endregion
        GameObject TurretTransform = new GameObject("TurretTransform");
        GameObject GunTransform    = new GameObject("GunTransform");
        GameObject GunDymTransform = new GameObject("GunDym");

        VehicleComponentsReferenceManager referenceManager = InstanceMesh.AddComponent <VehicleComponentsReferenceManager>();

        //GameObject MainHitBox = new GameObject ("MainHitBox");
        //GameObject TurretHitBox = new GameObject ("TurretHitBox");


        TurretTransform.transform.SetParent(InstanceMesh.transform);
        TurretTransform.transform.position = Turret.transform.position;

        GunTransform.transform.position = Gun.transform.position;
        Turret.parent = TurretTransform.transform;

        Gun.parent = GunTransform.transform;
        GunTransform.transform.SetParent(TurretTransform.transform);

        GunDymTransform.transform.position = GunDym.transform.position;
        GunDymTransform.transform.SetParent(GunTransform.transform);
        GunDym.SetParent(GunDymTransform.transform);

        #region 发射动画
        Animator FireAnimator = GunDymTransform.AddComponent <Animator> ();
        FireAnimator.runtimeAnimatorController = vehicleData.vehicleTextData.TFParameter.GymAnimation;
        #endregion

        AddDumpNode("FFPoint", GunTransform.transform, true, referenceManager);
        AddDumpNode("EffectStart", GunTransform.transform, true, referenceManager);
        AddDumpNode("FireForceFeedbackPoint", InstanceMesh.transform, true, referenceManager);
        AddDumpNode("EngineSmoke", InstanceMesh.transform, true, referenceManager);
        AddDumpNode("EngineSound", InstanceMesh.transform, true, referenceManager);
        AddDumpNode("MainCameraFollowTarget", InstanceMesh.transform, true, referenceManager);
        AddDumpNode("MainCameraGunner", GunTransform.transform, true, referenceManager);
        AddDumpNode("MachineGunFFPoint", TurretTransform.transform, true, referenceManager);
        AddDumpNode("CenterOfGravity", InstanceMesh.transform, true, referenceManager);



        //MainHitBox.transform.parent = TankModel.transform;
        //TurretHitBox.transform.parent = TurretTransform.transform;

        //EngineSmoke.transform.parent = TankModel.transform;
        //EngineSmoke.tag = "EngineSmoke";



        //		GameObject LODMesh = new GameObject ("LODMesh");
        //		LODMesh.transform.SetParent (TankModel.transform);
        //		LODMesh.tag = "LODMesh";

        GameObject HitBoxInstance = Instantiate <GameObject> (vehicleData.modelData.HitBox.HitBoxPrefab);
        HitBoxInstance.transform.Find("Main").name = "MainHitBox";
        HitBoxInstance.transform.Find("MainHitBox").SetParent(InstanceMesh.transform);

        HitBoxInstance.transform.Find("Turret").name = "TurretHitBox";
        HitBoxInstance.transform.Find("TurretHitBox").SetParent(TurretTransform.transform);

        HitBoxInstance.transform.Find("Gun").name = "GunHitBox";
        HitBoxInstance.transform.Find("GunHitBox").SetParent(GunTransform.transform);

        HitBoxInstance.transform.Find("Dym").name = "DymHitBox";
        HitBoxInstance.transform.Find("DymHitBox").SetParent(GunDymTransform.transform);

        DestroyImmediate(HitBoxInstance);
        //HitBoxInstance.transform.Find("Dym").SetParent()
        Restore(LeftWheel.GetComponentsInChildren <Transform> ());
        Restore(RightWheel.GetComponentsInChildren <Transform> ());

        Restore(LeftUpperWheels.GetComponentsInChildren <Transform> ());
        Restore(RightUpperWheels.GetComponentsInChildren <Transform> ());

        new GameObject("MainCameraTarget").transform.SetParent(TurretTransform.transform);

        TankInitSystem initySystem = TankPrefabs.AddComponent <TankInitSystem>();
        initySystem.PSParameter  = vehicleData.vehicleTextData.PSParameter;
        initySystem.TFParameter  = vehicleData.vehicleTextData.TFParameter;
        initySystem.MTParameter  = vehicleData.vehicleTextData.MTParameter;
        initySystem.PTCParameter = vehicleData.vehicleTextData.PTCParameter;

        return(initySystem);
    }