Exemple #1
0
    static void PackAndroidApp()
    {
        Debug.LogError("android package ----- 1");
        var start = DateTime.Now;

        Debug.LogError("android package ----- 2");
        BuildTarget buildTarget = BuildTarget.Android;
        ChannelType channelType = ChannelType.Test;

        Debug.LogError("android package ----- 3");

        AssetBundleDispatcherInspector.hasAnythingModified = true;
        BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString());
        AssetBundleDispatcherInspector.hasAnythingModified = false;
        Debug.LogError("android package ----- 4");

        AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts();
        Debug.LogError("android package ----- 5");

        PackageTool.BuildAndroidPlayerForCurrentChannel();
        Debug.LogError("android package ----- 6");

        var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString());

        EditorUtils.ExplorerFolder(folder);
        Debug.LogError("android package ----- 7");

        Debug.LogError($"Android Package Success!!! Use Time {(DateTime.Now - start).TotalSeconds}");
    }
Exemple #2
0
    public static void IosAutoBuildIphone()
    {
        InvalidDataParam();
        string xcodepath = GetJenkinsParameter("xcodePath");

        if (genXluaCode)
        {
            PackageTool.GenXLuaCode(buildTargetIOS);
        }
        if (isDelAllRes)
        {
            string outputPath2 = PackageUtils.GetCurBuildSettingAssetBundleOutputPath();
            GameUtility.SafeDeleteDir(outputPath2);
            Debug.Log(string.Format("Clear done : {0}", outputPath2));
        }
        if (isBuildRes)
        {
            PackageTool.AutoBuildPack(buildTargetIOS, GameChannel.ChannelType.Ljsd);
            PackageTool.BuildAssetBundlesForCurrentChannel();
            Debug.Log("BuildRes done " + buildTargetIOS.ToString());
            PackageUtils.CopyCurSettingAssetBundlesToStreamingAssets(buildTargetIOS);
        }

        Debug.Log("开始构建安装包参数");
        if (!string.IsNullOrEmpty(res_url))
        {
            var path = AssetBundles.LaunchAssetBundleServer.GetStreamingAssetBundleServerUrl();
            GameUtility.SafeWriteAllText(path, res_url);
            Debug.Log(res_url);
        }
        GameChannel.BaseChannel channel = GameChannel.ChannelManager.instance.CreateChannel(channelType.ToString());
        if (channel != null)
        {
            PlayerSettings.applicationIdentifier = channel.GetBundleID();
            PlayerSettings.productName           = channel.GetProductName();
            PlayerSettings.companyName           = channel.GetCompanyName();
            //Bundle version code自动加一
            string strnumber = PlayerSettings.iOS.buildNumber;
            int    number    = int.Parse(strnumber);
            number++;
            PlayerSettings.iOS.buildNumber                 = number.ToString();
            PlayerSettings.iOS.applicationDisplayName      = PlayerSettings.productName;
            PlayerSettings.iOS.appleEnableAutomaticSigning = true;
            PlayerSettings.iOS.appleDeveloperTeamID        = "K38NUKF4UV";
        }
        PlayerSettings.stripEngineCode = false;
        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, "HOTFIX_ENABLE;UNITY_POST_PROCESSING_STACK_V2");

        System.DateTime dt = System.DateTime.Now;
        //appName = appName + "-" + string.Format("{0:MM-dd}", dt) + "-"+ PlayerSettings.iOS.buildNumber;


        //xcodepath = Path.Combine(xcodepath, appName);
        Debug.Log("开始打包 path:" + xcodepath);
        BuildPipeline.BuildPlayer(BuildPlayer.GetBuildScenes(), xcodepath, buildTargetIOS, BuildOptions.None);
    }
    public static void BuildAssetBundlesForAllChannels()
    {
        var start = DateTime.Now;

        BuildPlayer.BuildAssetBundlesForAllChannels(buildTarget);

        var buildTargetName = PackageUtils.GetPlatformName(buildTarget);

        EditorUtility.DisplayDialog("Success", string.Format("Build AssetBundles for : \n\nplatform : {0} \nchannel : all \n\ndone! use {1}s", buildTargetName, (DateTime.Now - start).TotalSeconds), "Confirm");
    }
Exemple #4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {   //Singleton Algorythm
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Exemple #5
0
    public static void BuildAssetBundlesForCurrentChannel()
    {
        IncreaseResSubVersion();

        var start = DateTime.Now;

        BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString());

        var buildTargetName = PackageUtils.GetPlatformName(buildTarget);

        EditorUtility.DisplayDialog("Success", string.Format("Build AssetBundles for : \n\nplatform : {0} \nchannel : {1} \n\ndone! use {2}s",
                                                             buildTargetName, channelType, (DateTime.Now - start).TotalSeconds), "Confirm");
    }
    public static void BuildIOSPlayerForCurrentChannel()
    {
        if (CheckSymbolsToCancelBuild())
        {
            return;
        }

        var start = DateTime.Now;

        BuildPlayer.BuildXCode(channelType.ToString(), channelType == ChannelType.Test);

        var buildTargetName = PackageUtils.GetPlatformName(buildTarget);

        EditorUtility.DisplayDialog("Success", string.Format("Build player for : \n\nplatform : {0} \nchannel : {1} \n\ndone! use {2}s", buildTargetName, channelType, (DateTime.Now - start).TotalSeconds), "Confirm");
    }
Exemple #7
0
        static void CheckSimulateModelEnv()
        {
            if (!AssetBundleConfig.IsSimulateMode)
            {
                return;
            }

            var  buildTargetName      = PackageUtils.GetCurPlatformName();
            var  channelName          = PackageUtils.GetCurSelectedChannel().ToString();
            var  outputManifest       = PackageUtils.GetCurBuildSettingAssetBundleManifestPath();
            bool hasBuildAssetBundles = false;

            if (!File.Exists(outputManifest))
            {
                bool checkBuild = EditorUtility.DisplayDialog("Build AssetBundles Warning",
                                                              string.Format("Build AssetBundles for : \n\nplatform : {0} \nchannel : {1} \n\nContinue ?", buildTargetName, channelName),
                                                              "Confirm", "Cancel");
                if (!checkBuild)
                {
                    ToggleEditorMode();
                    return;
                }

                hasBuildAssetBundles = true;
                BuildPlayer.BuildAssetBundlesForCurSetting();
            }

            var streamingManifest = PackageUtils.GetCurBuildSettingStreamingManifestPath();

            if (hasBuildAssetBundles || !File.Exists(streamingManifest))
            {
                bool checkCopy = EditorUtility.DisplayDialog("Copy AssetBundles To StreamingAssets Warning",
                                                             string.Format("Copy AssetBundles to streamingAssets folder for : \n\nplatform : {0} \nchannel : {1} \n\nContinue ?", buildTargetName, channelName),
                                                             "Confirm", "Cancel");
                if (!checkCopy)
                {
                    ToggleEditorMode();
                    return;
                }

                // 拷贝到StreamingAssets目录时,相当于执行大版本更新,那么沙盒目录下的数据就作废了
                // 真机上会对比这两个目录下的App版本号来删除,编辑器下暴力一点,直接删除
                ToolsClearPersistentAssets();
                PackageUtils.CopyCurSettingAssetBundlesToStreamingAssets(EditorUserBuildSettings.activeBuildTarget);
            }
            LaunchAssetBundleServer.CheckAndDoRunning();
        }
    public static void BuildIOSPlayerForAllChannels()
    {
        if (CheckSymbolsToCancelBuild())
        {
            return;
        }

        var start = DateTime.Now;

        foreach (var current in (ChannelType[])Enum.GetValues(typeof(ChannelType)))
        {
            BuildPlayer.BuildXCode(current.ToString(), channelType == ChannelType.Test);
        }

        var buildTargetName = PackageUtils.GetPlatformName(buildTarget);

        EditorUtility.DisplayDialog("Success", string.Format("Build player for : \n\nplatform : {0} \nchannel : all \n\ndone! use {2}s", buildTargetName, (DateTime.Now - start).TotalSeconds), "Confirm");
    }
        static void CheckSimulateModelEnv()
        {
            if (!AssetBundleConfig.IsSimulateMode)
            {
                return;
            }

            var  buildTargetName      = PackageUtils.GetCurPlatformName();
            var  channelName          = PackageUtils.GetCurSelectedChannel().ToString();
            var  outputManifest       = PackageUtils.GetCurBuildSettingOutputManifestPath();
            bool hasBuildAssetBundles = false;

            if (!File.Exists(outputManifest))
            {
                bool checkBuild = EditorUtility.DisplayDialog("Build AssetBundles Warning",
                                                              string.Format("Build AssetBundles for : \n\nplatform : {0} \nchannel : {1} \n\nContinue ?", buildTargetName, channelName),
                                                              "Confirm", "Cancel");
                if (!checkBuild)
                {
                    ToggleEditorMode();
                    return;
                }

                hasBuildAssetBundles = true;
                BuildPlayer.BuildAssetBundlesForCurSetting();
            }

            var streamingManifest = PackageUtils.GetCurBuildSettingStreamingManifestPath();

            if (hasBuildAssetBundles || !File.Exists(streamingManifest))
            {
                bool checkCopy = EditorUtility.DisplayDialog("Copy AssetBundles To StreamingAssets Warning",
                                                             string.Format("Copy AssetBundles to streamingAssets folder for : \n\nplatform : {0} \nchannel : {1} \n\nContinue ?", buildTargetName, channelName),
                                                             "Confirm", "Cancel");
                if (!checkCopy)
                {
                    ToggleEditorMode();
                    return;
                }

                PackageUtils.CopyCurSettingAssetBundlesToStreamingAssets();
            }
            LaunchAssetBundleServer.CheckAndDoRunning();
        }
Exemple #10
0
 /////////////////////////////////////////////////////
 ///  DoBuildUp(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Raw buildup, you can build anything on top of each other, exept the position, there is no AI
 /////////////////////////////////////////////////////
 private static void DoBuildUp(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     var fbuildingblock = baseentity.GetComponentInParent<BuildingBlock>();
     if (fbuildingblock == null)
     {
         return;
     }
     newPos = fbuildingblock.transform.position + (VectorUP * buildplayer.currentHeightAdjustment);
     newRot = fbuildingblock.transform.rotation;
     if (isColliding(buildplayer.currentPrefab, newPos, 1f))
     {
         return;
     }
     SpawnStructure(buildplayer.currentPrefab, newPos, newRot, buildplayer.currentGrade, buildplayer.currentHealth);
 }
Exemple #11
0
 /////////////////////////////////////////////////////
 ///  DoSpawn(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Raw spawning building elements, no AI here
 /////////////////////////////////////////////////////
 private static void DoSpawn(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     newPos = closestHitpoint + (VectorUP * buildplayer.currentHeightAdjustment);
     newRot = currentRot;
     newRot.x = 0f;
     newRot.z = 0f;
     SpawnStructure(buildplayer.currentPrefab, newPos, newRot, buildplayer.currentGrade, buildplayer.currentHealth);
 }
Exemple #12
0
        /////////////////////////////////////////////////////
        ///  DoHeal(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        ///  Set max health to building
        /////////////////////////////////////////////////////
        private static void DoHeal(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var buildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (buildingblock == null)
            {
                return;
            }
            SetHealth(buildingblock);
            if (buildplayer.selection == "select")
            {
                return;
            }

            houseList = new List<object>();
            checkFrom = new List<Vector3>();
            houseList.Add(buildingblock);
            checkFrom.Add(buildingblock.transform.position);
		int current = 0;
            while (true)
            {
                current++;
                if (current > checkFrom.Count)
                    break;
                List<BaseEntity> list = Pool.GetList<BaseEntity>();
                Vis.Entities<BaseEntity>(checkFrom[current - 1], 3f, list, constructionColl);
                 for (int i = 0; i < list.Count; i++)
                {
                    BaseEntity hit = list[i];
                    var fbuildingblock = hit.GetComponentInParent<BuildingBlock>();
                    if (fbuildingblock != null && !(houseList.Contains(fbuildingblock)))
                    {
                        houseList.Add(fbuildingblock);
                        checkFrom.Add(fbuildingblock.transform.position);
                        SetHealth(fbuildingblock);
                    }
                }
            }
        }
Exemple #13
0
        private static void DoRotation(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var buildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (buildingblock == null)
            {
                return;
            }
            DoRotation(buildingblock, buildplayer.currentRotate);
            if (buildplayer.selection == "select")
            {
                return;
            }

            houseList = new List<object>();
            checkFrom = new List<Vector3>();
            houseList.Add(buildingblock);
            checkFrom.Add(buildingblock.transform.position);

            int current = 0;
            while (true)
            {
                current++;
                if (current > checkFrom.Count)
                    break;
                var hits = Physics.OverlapSphere(checkFrom[current - 1], 3.1f);
                foreach (var hit in hits)
                {
                    var fbuildingblock = hit.GetComponentInParent<BuildingBlock>();
                    if (fbuildingblock != null && !(houseList.Contains(fbuildingblock)))
                    {
                        houseList.Add(fbuildingblock);
                        checkFrom.Add(fbuildingblock.transform.position);
                        DoRotation(fbuildingblock, buildplayer.currentRotate);
                    }
                }
            }
        }
Exemple #14
0
 /////////////////////////////////////////////////////
 ///  DoDeploy(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Deploy Deployables
 /////////////////////////////////////////////////////
 private static void DoDeploy(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     newPos = closestHitpoint + (VectorUP * buildplayer.currentHeightAdjustment);
     newRot = currentRot;
     newRot.x = 0f;
     newRot.z = 0f;
     SpawnDeployable(buildplayer.currentPrefab, newPos, newRot, currentplayer);
 }
Exemple #15
0
 /////////////////////////////////////////////////////
 ///  DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Erase function
 /////////////////////////////////////////////////////
 private static void DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     currentBaseNet = baseentity.GetComponentInParent<BaseNetworkable>();
     currentBaseNet?.Kill(BaseNetworkable.DestroyMode.Gib);
 }
Exemple #16
0
    void DrawAssetBundlesGUI()
    {
        GUILayout.Space(3);
        GUILayout.Label("-------------[Build AssetBundles]-------------");
        GUILayout.BeginHorizontal();
//        if (buildTarget == BuildTarget.Android)
//        {
//            GUILayout.Label("Android Lua打包成Ab : ", GUILayout.Width(150));
//            AssetBundleConfig.IsPackLuaAb = EditorGUILayout.Toggle(AssetBundleConfig.IsPackLuaAb, GUILayout.Width(50));
//        }
        GUILayout.EndHorizontal();
        GUILayout.Space(3);

        GUILayout.Space(3);

        GUILayout.BeginHorizontal();
        if (buildABSForPerChannel)
        {
            if (GUILayout.Button("Current Channel Only", GUILayout.Width(200)))
            {
                EditorApplication.delayCall += BuildAssetBundlesForCurrentChannel;
            }
            if (GUILayout.Button("For All Channels", GUILayout.Width(200)))
            {
                EditorApplication.delayCall += BuildAssetBundlesForAllChannels;
            }
            if (GUILayout.Button("Open Current Output", GUILayout.Width(200)))
            {
                AssetBundleMenuItems.ToolsOpenOutput();
            }
            if (GUILayout.Button("Copy To StreamingAsset", GUILayout.Width(200)))
            {
                AssetBundleMenuItems.ToolsCopyAssetbundles();
                AssetDatabase.Refresh();
            }
        }
        else
        {
            if (GUILayout.Button("打包ab包并拷贝", GUILayout.Width(200)))
            {
                var start = DateTime.Now;
                EditorApplication.delayCall += BuildAssetBundlesForCurrentChannel;
                EditorApplication.delayCall += () =>
                {
                    AssetBundleMenuItems.ToolsCopyAssetbundles();
                    AssetDatabase.Refresh();
                };
                EditorApplication.delayCall += () =>
                {
                    EditorUtility.DisplayDialog("打包完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm");
                };
            }
            if (GUILayout.Button("打开ab包目录", GUILayout.Width(200)))
            {
                AssetBundleMenuItems.ToolsOpenOutput();
            }
            if (GUILayout.Button("生成引用计数大于1的资源目录", GUILayout.Width(200)))
            {
                EditorApplication.delayCall += () =>
                {
                    CheckAllDependenciesRes();
                };
                EditorApplication.delayCall += () =>
                {
                    CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile);
                };
            }
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();
        if (GUILayout.Button("拷贝Lua的代码", GUILayout.Width(200)))
        {
            var start = DateTime.Now;
            AssetBundleMenuItems.ToolsCopyLuaScriptsToAssetbundles();
            AssetDatabase.Refresh();
            EditorApplication.delayCall += () =>
            {
                EditorUtility.DisplayDialog("拷贝Lua代码完成", $" 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm");
            };
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("打包拷贝ab&拷贝lua", GUILayout.Width(200)))
        {
            var start = DateTime.Now;
            EditorApplication.delayCall += () =>
            {
                AssetBundleDispatcherInspector.hasAnythingModified = true;
                BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString());
                AssetBundleDispatcherInspector.hasAnythingModified = false;
            };
            EditorApplication.delayCall += () =>
            {
                CMDController.ExcuteCmdFile();
            };
            EditorApplication.delayCall += () =>
            {
                AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts();
            };
            EditorApplication.delayCall += () =>
            {
                EditorUtility.DisplayDialog("一键完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; Copy LuaSciptsToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm");
            };
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("一键+打包", GUILayout.Width(200)))
        {
            var start = DateTime.Now;
            EditorApplication.delayCall += () =>
            {
                AssetBundleDispatcherInspector.hasAnythingModified = true;
                BuildPlayer.BuildAssetBundles(buildTarget, channelType.ToString());
                AssetBundleDispatcherInspector.hasAnythingModified = false;
            };
            EditorApplication.delayCall += () =>
            {
                AssetBundleMenuItems.ToolsCopyAssetbundlesAndScripts();
            };

            EditorApplication.delayCall += CheckAllDependenciesRes;

            EditorApplication.delayCall += BuildAndroidPlayerForCurrentChannel;

            EditorApplication.delayCall += () =>
            {
                CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile);
            };

            EditorApplication.delayCall += () =>
            {
                var folder = PackageUtils.GetChannelOutputPath(buildTarget, channelType.ToString());
                EditorUtils.ExplorerFolder(folder);
            };

            EditorApplication.delayCall += () =>
            {
                EditorUtility.DisplayDialog("一键完成", $"RunAllCheckres; ExecuteBuild; CopyToStreamingAsset; Copy LuaSciptsToStreamingAsset; 使用时长为:{(DateTime.Now - start).TotalSeconds}", "Confirm");
            };
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("准备热更新资源", GUILayout.Width(200)))
        {
            CMDController.ExcuteCmdFile(CMDController.CMDHotUpdateFile);
        }
        GUILayout.Space(3);
    }
Exemple #17
0
 public static void CreateVHMsgEmulatorApp()
 {
     BuildPlayer.PerformBuild(BuildTarget.StandaloneWindows, "BuildSettingsVHMsgEmulator.xml");
 }
Exemple #18
0
    public static void IosAutoBuildApk()
    {
        InvalidDataParam();
        if (genXluaCode)
        {
            PackageTool.GenXLuaCode(buildTarget);
        }
        if (isDelAllRes)
        {
            string outputPath2 = PackageUtils.GetCurBuildSettingAssetBundleOutputPath();
            GameUtility.SafeDeleteDir(outputPath2);
            Debug.Log(string.Format("Clear done : {0}", outputPath2));
        }
        if (isBuildRes)
        {
            PackageTool.AutoBuildPack(buildTarget, GameChannel.ChannelType.Ljsd);
            PackageTool.BuildAssetBundlesForCurrentChannel();
            Debug.Log("BuildRes done " + buildTarget.ToString());
            PackageUtils.CopyCurSettingAssetBundlesToStreamingAssets(buildTarget);
        }

        Debug.Log("开始构建安装包参数");
        if (!string.IsNullOrEmpty(res_url))
        {
            var path = AssetBundles.LaunchAssetBundleServer.GetStreamingAssetBundleServerUrl();
            GameUtility.SafeWriteAllText(path, res_url);
            Debug.Log(res_url);
        }

        GameChannel.BaseChannel channel = GameChannel.ChannelManager.instance.CreateChannel(channelType.ToString());
        if (isCpp)
        {
            PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
        }
        else
        {
            PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x);
        }
        if (channel != null)
        {
#if UNITY_5_6_OR_NEWER
            PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, channel.GetBundleID());
#else
            PlayerSettings.bundleIdentifier = channel.GetBundleID();
#endif
            PlayerSettings.productName = channel.GetProductName();
            PlayerSettings.companyName = channel.GetCompanyName();
        }
        PlayerSettings.stripEngineCode = false;
        string          savePath = GetJenkinsParameter("outPath");
        System.DateTime dt       = System.DateTime.Now;
        appName = appName + "-" + string.Format("{0:MM-dd-HH-mm-ss-ffff}", dt) + ".apk";
        if (channel.IsGooglePlay())
        {
            savePath = Path.Combine(savePath, "GooglePlay");
            GameUtility.SafeDeleteDir(savePath);
            BuildPipeline.BuildPlayer(BuildPlayer.GetBuildScenes(), savePath, buildTarget, BuildOptions.AcceptExternalModificationsToPlayer);
        }
        else
        {
            Debug.Log("开始打包");
            savePath = Path.Combine(savePath, appName);
            BuildPipeline.BuildPlayer(BuildPlayer.GetBuildScenes(), savePath, buildTarget, BuildOptions.None);
        }

        Debug.Log(string.Format("Build android player for : {0} done! output :{1}", channelType.ToString(), savePath));
        //bool.Parse(GetJenkinsParameter("GetJenkinsParameter"));
    }
Exemple #19
0
    public void DrawSettingsPart()
    {
        string description;
        string tooltip;
        string labelTitle;

        description = "SoundbanksInfo.xml file path:";
        tooltip     =
            "需要转换的文件地址";
        labelTitle = "需要转换的文件地址";

        UnityEngine.GUILayout.Label(labelTitle, UnityEditor.EditorStyles.boldLabel);

        var OpenInPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                                 ""));

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            UnityEngine.GUILayout.Label(new UnityEngine.GUIContent(description, tooltip), UnityEngine.GUILayout.Width(330));

            if (ConverFileSrcPath.Length > 0)
            {
                OpenInPath = ConverFileSrcPath;
            }
            UnityEditor.EditorGUILayout.SelectableLabel(ConverFileSrcPath, "textfield",
                                                        UnityEngine.GUILayout.Height(17));
            if (UnityEngine.GUILayout.Button("...", UnityEngine.GUILayout.Width(30)))
            {
                var WwiseProjectPathNew = UnityEditor.EditorUtility.OpenFilePanel("Select need Convert file", OpenInPath, "xml");
                if (WwiseProjectPathNew.Length != 0)
                {
                    if (WwiseProjectPathNew.EndsWith(".xml") == false)
                    {
                        UnityEditor.EditorUtility.DisplayDialog("Error", "Please select a valid .wproj file", "Ok");
                    }
                    else
                    {
                        ConverFileSrcPath = WwiseProjectPathNew;
                        if (ConverFileSrcPath.Length > 4)
                        {
                            int    Spindex  = ConverFileSrcPath.LastIndexOf("/");
                            string filename = ConverFileSrcPath.Substring(Spindex, ConverFileSrcPath.Length - Spindex - 4);
                            filename += ".txt";
                            // outputfilename = filename;
                        }
                    }
                }

                Repaint();
            }
        }


        description = "SoundbanksInfo.txt Path:";
        tooltip     = "导" +
                      "导出文件的位置";
        labelTitle = "导出文件的位置";

        UnityEngine.GUILayout.Label(labelTitle, UnityEditor.EditorStyles.boldLabel);

        using (new UnityEngine.GUILayout.HorizontalScope("box"))
        {
            UnityEngine.GUILayout.Label(new UnityEngine.GUIContent(description, tooltip), UnityEngine.GUILayout.Width(330));


            UnityEditor.EditorGUILayout.SelectableLabel(ConverFileDstPath, "textfield", UnityEngine.GUILayout.Height(17));

            if (UnityEngine.GUILayout.Button("...", UnityEngine.GUILayout.Width(30)))
            {
#if UNITY_EDITOR_OSX
                var installationPathNew = UnityEditor.EditorUtility.SaveFolderPanel("Select your output path.",
                                                                                    OpenInPath, "");
#else
                var installationPathNew = UnityEditor.EditorUtility.OpenFolderPanel("Select your ouput path.", OpenInPath, "");
                //System.Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "");
#endif

                if (installationPathNew.Length != 0)
                {
                    ConverFileDstPath = System.IO.Path.GetFullPath(installationPathNew);
                }

                Repaint();
            }
        }
        // UnityEngine.GUILayout.Label("In Editor Warnings", UnityEditor.EditorStyles.boldLabel);

        //using (new UnityEngine.GUILayout.VerticalScope("box"))
        //{
        //    description = "Show Warning for Missing RigidBody";
        //    tooltip =
        //        "Interactions between AkGameObj and AkEnvironment or AkRoom require a Rigidbody component on the object or the environment/room. It is recommended to leave this box checked.";
        //    WwiseSetupWizard.Settings.ShowMissingRigidBodyWarning = UnityEngine.GUILayout.Toggle(
        //        WwiseSetupWizard.Settings.ShowMissingRigidBodyWarning, new UnityEngine.GUIContent(description, tooltip));
        //}

        //using (new UnityEngine.GUILayout.HorizontalScope())
        //{
        //    UnityEngine.GUILayout.Label("* Mandatory settings");
        //}
        if (GUILayout.Button("开始转换", GUILayout.Width(200)))
        {
            Logger.Log("原始文件:" + ConverFileSrcPath);
            string dst = Path.Combine(ConverFileDstPath, outputfilename);
            Logger.Log("输出文件:" + ConverFileDstPath);
            Logger.Log("输出文件:" + dst);
            if (BuildPlayer.ConvertXml2Json(ConverFileSrcPath, dst))
            {
                EditorUtility.DisplayDialog("转换音效文件", "转换成功!!!!", "确定");
            }
        }
        UnityEngine.GUILayout.FlexibleSpace();
    }
Exemple #20
0
        /////////////////////////////////////////////////////
        ///  DoBuild(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        ///  Fully AIed Build :) see the InitializeSockets for more informations
        /////////////////////////////////////////////////////
        private static void DoBuild(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
        {
            var fbuildingblock = baseentity.GetComponentInParent<BuildingBlock>();
            if (fbuildingblock == null)
            {
                return;
            }
            distance = 999999f;
            Vector3 newPos = new Vector3(0f, 0f, 0f);
            newRot = new Quaternion(0f, 0f, 0f, 0f);
            //  Checks if this building has a socket hooked to it self
            //  If not ... well it won't be able to be built via AI
            if (nameToSockets.ContainsKey(fbuildingblock.blockDefinition.fullName))
            {
                sourcesocket = nameToSockets[fbuildingblock.blockDefinition.fullName];
                // Gets all Sockets that can be connected to the source building
                if (TypeToType.ContainsKey(sourcesocket))
                {
                    sourceSockets = (Dictionary<SocketType, object>)TypeToType[sourcesocket];
                    targetsocket = nameToSockets[buildplayer.currentPrefab];
                    // Checks if the newly built structure can be connected to the source building
                    if (sourceSockets.ContainsKey(targetsocket))
                    {
                        newsockets = (Dictionary<Vector3, Quaternion>)sourceSockets[targetsocket];
                        // Get all the sockets that can be hooked to the source building via the new structure element
                        foreach (KeyValuePair<Vector3, Quaternion> pair in newsockets)
                        {
                            var currentrelativepos = (fbuildingblock.transform.rotation * pair.Key) + fbuildingblock.transform.position;
                            if (Vector3.Distance(currentrelativepos, closestHitpoint) < distance)
                            {
                                // Get the socket that is the closest to where the player is aiming at
                                distance = Vector3.Distance(currentrelativepos, closestHitpoint);
                                newPos = currentrelativepos + (VectorUP * buildplayer.currentHeightAdjustment);
                                newRot = (fbuildingblock.transform.rotation * pair.Value);
                            }
                        }
                    }
                }
            }
            if (newPos.x == 0f)
                return;
            // Checks if the element has already been built to prevent multiple structure elements on one spot
            if (isColliding(buildplayer.currentPrefab, newPos, 1f))
                return;

            SpawnStructure(buildplayer.currentPrefab, newPos, newRot, buildplayer.currentGrade, buildplayer.currentHealth);
        }
Exemple #21
0
 /////////////////////////////////////////////////////
 ///  DoAction(BuildPlayer buildplayer)
 ///  Called from the BuildPlayer, will handle all different building types
 /////////////////////////////////////////////////////
 private static void DoAction(BuildPlayer buildplayer)
 {
     currentplayer = buildplayer.player;
     if (!TryGetPlayerView(currentplayer, out currentRot))
     {
         return;
     }
     if (!TryGetClosestRayPoint(currentplayer.transform.position, currentRot, out closestEnt, out closestHitpoint))
     {
         return;
     }
     currentCollider = closestEnt as Collider;
     if (currentCollider == null)
     {
         return;
     }
     switch (buildplayer.currentType)
     {
         case "building":
             DoBuild(buildplayer, currentplayer, currentCollider);
             break;
         case "buildup":
             DoBuildUp(buildplayer, currentplayer, currentCollider);
             break;
         case "deploy":
             DoDeploy(buildplayer, currentplayer, currentCollider);
             break;
         case "plant":
         case "animal":
             DoPlant(buildplayer, currentplayer, currentCollider);
             break;
         case "grade":
             DoGrade(buildplayer, currentplayer, currentCollider);
             break;
         case "heal":
             DoHeal(buildplayer, currentplayer, currentCollider);
             break;
         case "erase":
             DoErase(buildplayer, currentplayer, currentCollider);
             break;
         case "rotate":
             DoRotation(buildplayer, currentplayer, currentCollider);
             break;
         case "spawning":
             DoSpawn(buildplayer, currentplayer, currentCollider);
             break;
         default:
             return;
     }
 }
Exemple #22
0
    public static void AutoBuildApk()
    {
        buildTarget = EditorUserBuildSettings.activeBuildTarget;
        bool   isDelAllRes = false;
        string temp        = GetJenkinsParameter("isDelAllRes");

        if (!string.IsNullOrEmpty(temp))
        {
            isDelAllRes = bool.Parse(temp);
        }
        bool isBuildRes = false;

        temp = GetJenkinsParameter("isBuildRes");
        if (!string.IsNullOrEmpty(temp))
        {
            isBuildRes = bool.Parse(temp);
        }
        bool genXluaCode = false;

        temp = GetJenkinsParameter("genXluaCode");
        if (!string.IsNullOrEmpty(temp))
        {
            genXluaCode = bool.Parse(temp);
        }
        bool isCpp = false;

        temp = GetJenkinsParameter("isCpp");
        if (!string.IsNullOrEmpty(temp))
        {
            isCpp = bool.Parse(temp);
        }
        if (isDelAllRes)
        {
            string outputPath2 = PackageUtils.GetCurBuildSettingAssetBundleOutputPath();
            GameUtility.SafeDeleteDir(outputPath2);
            Debug.Log(string.Format("Clear done : {0}", outputPath2));
        }
        temp = GetJenkinsParameter("channel");
        if (!string.IsNullOrEmpty(temp))
        {
            channelType = (GameChannel.ChannelType)Enum.Parse(typeof(GameChannel.ChannelType), temp);
        }
        if (isBuildRes)
        {
            PackageTool.AutoBuildPack(buildTarget, channelType);
            PackageTool.BuildAssetBundlesForCurrentChannel();
            Debug.Log("BuildRes done ");
            PackageUtils.CopyCurSettingAssetBundlesToStreamingAssets(buildTarget);
        }
        if (genXluaCode)
        {
            PackageTool.GenXLuaCode(buildTarget);
        }
        Debug.Log("开始构建安装包参数");
        string res_url = GetJenkinsParameter("res_url");

        if (!string.IsNullOrEmpty(res_url))
        {
            var path = AssetBundles.LaunchAssetBundleServer.GetStreamingAssetBundleServerUrl();
            GameUtility.SafeWriteAllText(path, res_url);
            Debug.Log(res_url);
        }

        GameChannel.BaseChannel channel = GameChannel.ChannelManager.instance.CreateChannel(channelType.ToString());
        if (isCpp)
        {
            PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
        }
        else
        {
            PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x);
        }
        PlayerSettings.stripEngineCode            = false;
        PlayerSettings.SplashScreen.showUnityLogo = false;
        if (channel != null)
        {
#if UNITY_5_6_OR_NEWER
            PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, channel.GetBundleID());
#else
            PlayerSettings.bundleIdentifier = channel.GetBundleID();
#endif
            PlayerSettings.productName = channel.GetProductName();
            PlayerSettings.companyName = channel.GetCompanyName();
        }

        string savePath = "E:\\APK";
        string appName  = GetJenkinsParameter("apkName") + ".apk";
        if (string.IsNullOrEmpty(appName))
        {
            appName = "zhj";
        }
        if (channel.IsGooglePlay())
        {
            savePath = Path.Combine(savePath, "GooglePlay");
            GameUtility.SafeDeleteDir(savePath);
            BuildPipeline.BuildPlayer(BuildPlayer.GetBuildScenes(), savePath, buildTarget, BuildOptions.AcceptExternalModificationsToPlayer);
        }
        else
        {
            Debug.Log("开始打包");
            savePath = Path.Combine(savePath, appName);
            BuildPipeline.BuildPlayer(BuildPlayer.GetBuildScenes(), savePath, buildTarget, BuildOptions.None);
        }

        Debug.Log(string.Format("Build android player for : {0} done! output :{1}", channelType.ToString(), savePath));
        //bool.Parse(GetJenkinsParameter("GetJenkinsParameter"));
    }