コード例 #1
0
    public string GetLine(int index, XElement item, CSVBuilder instance)
    {
        string buffer = "";

        foreach (var key in keys)
        {
            try {
                AutoCSVKeys.KeyDelegate spcKey;
                if (AutoCSVKeys.specialKeys.TryGetValue(key, out spcKey))
                {
                    buffer += spcKey(index, key, item.Attribute(key) != null ? item.Attribute(key).Value : "0", item, instance);
                }
                else
                {
                    buffer += (item.Attribute(key) != null ? item.Attribute(key).Value : "0") + ",";
                }
            } catch (Exception e) {
                Debug.LogError(string.Format("An Error Occured while getting values from mod.xml : {0}", key));
                Debug.LogWarning(e);
            }
        }
        buffer = buffer.Substring(0, buffer.Length - 1); // f****r

        buffer += "\n";
        return(buffer);
    }
コード例 #2
0
    private static void OnAssemblyCompilationStarted(string builtAssembly)
    {
        var fileInfo = new FileInfo(builtAssembly);

        if (!fileInfo.Exists)
        {
            return;
        }

        var assembly       = Assembly.LoadFile(fileInfo.FullName);
        var interfaceTypes = assembly.GetTypes()
                             .Where(t => t.IsInterface);

        foreach (var foundType in interfaceTypes)
        {
            var isInterop = foundType
                            .GetCustomAttributes(false)
                            .Any(a => a is GenerateBindingsAttribute);
            if (isInterop)
            {
                var interopInterfaceFile =
                    FindScriptForInterface(foundType);
                if (interopInterfaceFile == null)
                {
                    Debug.LogError("Interface " + interopInterfaceFile + " not found.");
                }
                else
                {
                    UpdateTachyonBindings(interopInterfaceFile);
                }
            }
        }
    }
コード例 #3
0
        protected override void doLog(rcLogCategory category, string msg)
        {
            m_Messages.Add(new LogMessage(category, msg));
            if (m_Messages.Count > MAX_MESSAGES)
            {
                m_Messages.RemoveAt(0);
            }


            m_Dirty = true;

            switch (category)
            {
            case rcLogCategory.RC_LOG_ERROR:
                Debug.LogError(msg);
                break;

            case rcLogCategory.RC_LOG_WARNING:
                Debug.LogWarning(msg);
                break;

            case rcLogCategory.RC_LOG_PROGRESS:
                Debug.Log(msg);
                break;
            }
        }
コード例 #4
0
    public void ConsoleTest()
    {
        var sw = new Stopwatch();

        sw.Start();
        for (var i = 0; i < ConsoleTestQuantity; i++)
        {
            var sample = SampleLogs[Random.Range(0, SampleLogs.Length)];

            var mode = Random.Range(0, 3);

            switch (mode)
            {
            case 0:
                Debug.Log(sample);
                break;

            case 1:
                Debug.LogWarning(sample);
                break;

            case 2:
                Debug.LogError(sample);
                break;
            }
        }
        sw.Stop();

        Debug.Log("Posted {0} log messages in {1}s".Fmt(ConsoleTestQuantity, sw.Elapsed.TotalSeconds));
    }
コード例 #5
0
    public static void BuildPatch()
    {
        var verfile = AppDataPath + "/version.txt";

        localVerInfo = Util.GetVersionInfo(verfile);
        if (localVerInfo == null)
        {
            Debug.LogError("Don't find version info, make first!!!");
            return;
        }
        if (TryCreateDir(patchPath))
        {
            UpdateOrCreateIndexFile();
            Debug.Log("First create index file.");
        }
        else
        {
            var needUpdateFiles = FindNeedUpdateFiles();
            if (needUpdateFiles != null && needUpdateFiles.Count > 0)
            {
                BuildPatchInternal(needUpdateFiles);
                //UpdateOrCreateIndexFile();
            }
            else
            {
                Debug.LogError("Don't find need update file.");
            }
        }
        AssetDatabase.Refresh();
    }
コード例 #6
0
ファイル: BuildMenu.cs プロジェクト: KonH/CSharp_AOP_Samples
    static bool Run(string command)
    {
        // Hack, because %PATH% inside Unity may be different on MacOS
        var oldPath = Environment.GetEnvironmentVariable("PATH");

        Environment.SetEnvironmentVariable("PATH", oldPath + ":/usr/local/share/dotnet/");

        var startInfo = new ProcessStartInfo {
            FileName               = "dotnet",
            Arguments              = command,
            RedirectStandardError  = true,
            RedirectStandardOutput = true,
            UseShellExecute        = false,
            CreateNoWindow         = true
        };

        try {
            using (var process = Process.Start(startInfo)) {
                process.WaitForExit();
                var output = process.StandardOutput.ReadToEnd() + "\n" + process.StandardError.ReadToEnd();
                if (process.ExitCode == 0)
                {
                    Debug.Log($"Success: '{command}'\n{output}");
                    return(true);
                }
                else
                {
                    Debug.LogError($"Failed: '{command}'\n{output}");
                }
            }
        } catch (Exception e) {
            Debug.LogError($"Failed: '{command}': {e}");
        }
        return(false);
    }
コード例 #7
0
    public override TypeDefinitionBase ReturnType()
    {
        if (returnType == null)
        {
            if (kind == SymbolKind.Constructor)
            {
                return(parentSymbol as TypeDefinitionBase ?? unknownType);
            }

            if (declarations != null)
            {
                SyntaxTreeNode_Base refNode = null;
                switch (declarations[0].parseTreeNode.RuleName)
                {
                case "methodDeclaration":
                case "interfaceMethodDeclaration":
                    refNode = declarations[0].parseTreeNode.FindPreviousNode();
                    break;

                default:
                    refNode = declarations[0].parseTreeNode.Parent.Parent.ChildAt(declarations[0].parseTreeNode.Parent.m_iChildIndex - 1);
                    break;
                }
                if (refNode == null)
                {
                    Debug.LogError("Could not find method return type from node: " + declarations[0].parseTreeNode);
                }
                returnType = refNode != null ? new SymbolReference(refNode) : null;
            }
        }

        return(returnType == null ? unknownType : returnType.Definition as TypeDefinitionBase ?? unknownType);
    }
コード例 #8
0
 public bool IsReady()
 {
     if (!isReady)
     {
         Debug.LogError("PXRLog Failed to initialize ADB Tool");
     }
     return(isReady);
 }
コード例 #9
0
 public bool IsReady()
 {
     if (!isReady)
     {
         Debug.LogError(ADB_NO_READ_STR);
     }
     return(isReady);
 }
コード例 #10
0
 public static void CopyFile(string formFileName, string toFileName)
 {
     try {
         File.Copy(formFileName, toFileName, true);
     } catch (Exception ex) {
         Debug.LogError(ex.Message);
     }
 }
コード例 #11
0
ファイル: GrpcHelper.cs プロジェクト: alecsandru95/unity_grpc
    private static void BuildProtoFiles()
    {
        Debug.Log("BuildProtoFiles");
        try
        {
            var protoExe      = Path.GetFullPath("Assets/Plugins/Grpc.Tools/protoc.exe");
            var grpcPluginExe = Path.GetFullPath("Assets/Plugins/Grpc.Tools/grpc_csharp_plugin.exe");

            if (File.Exists(protoExe) == false || File.Exists(grpcPluginExe) == false)
            {
                Debug.LogError($"Grpc Tool is missing, check [{protoExe}] and {grpcPluginExe}");
                return;
            }

            var protoFileExtension = ".proto";

            var protoFiles = Directory
                             .EnumerateFiles("Assets/", "*.*", SearchOption.AllDirectories)
                             .Where(f => Path.GetExtension(f).ToLowerInvariant().Equals(protoFileExtension)).Select(p => Path.GetFullPath(p));

            foreach (var protoFile in protoFiles)
            {
                try
                {
                    var protoFileName = Path.GetFileName(protoFile);
                    Debug.Log($"Compiling protofile : {protoFileName}");

                    var directory = Path.GetDirectoryName(protoFile);

                    var arguments = $"/k {protoExe} -I \"{directory}\" --plugin=protoc-gen-grpc=\"{grpcPluginExe}\" --csharp_out=\"{directory}\" --grpc_out=\"{directory}\" \"{protoFile}\"";
                    Debug.Log(arguments);

                    var processStartInfo = new ProcessStartInfo()
                    {
                        FileName               = "cmd.exe",
                        UseShellExecute        = false,
                        Arguments              = arguments,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        CreateNoWindow         = false
                    };
                    var rezultProcess = Process.Start(processStartInfo);

                    rezultProcess.WaitForExit();
                }
                catch (Exception exception)
                {
                    Debug.LogError($"Exception on file : {protoFile}\n{exception.Message}");
                }
            }
        }
        catch (Exception exception)
        {
            Debug.LogError(exception.Message);
        }
    }
コード例 #12
0
    public void InvokeEvent(GameEvents name, params object[] args)
    {
        if (!_events.ContainsKey(name))
        {
            Debug.LogError($"Event with id({name}) does not contain in EventList!");
            return;
        }

        _events[name].Invoke(args);
    }
コード例 #13
0
    static void LinsteCMD()
    {
        var index = 0;

        foreach (string var in System.Environment.GetCommandLineArgs())
        {
            index++;
            Debug.LogError($"get cmd params {index}:{var}");
        }
    }
コード例 #14
0
ファイル: GitUtils.cs プロジェクト: UltraStar-Deluxe/Play
    // Original implementation from https://www.stewmcc.com/post/git-commands-from-unity/
    public static string RunGitCommand(string gitCommand, bool throwOnFailure = true)
    {
        // Set up our processInfo to run the git command and log to output and errorOutput.
        ProcessStartInfo processInfo = new("git", gitCommand)
        {
            CreateNoWindow         = true,  // We want no visible pop-ups
            UseShellExecute        = false, // Allows us to redirect input, output and error streams
            RedirectStandardOutput = true,  // Allows us to read the output stream
            RedirectStandardError  = true   // Allows us to read the error stream
        };

        // Set up the Process
        Process process = new() { StartInfo = processInfo };

        try
        {
            // Try to start it, catching any exceptions if it fails
            process.Start();
        }
        catch (Exception e)
        {
            // For now just assume its failed cause it can't find git.
            Debug.LogException(e);
            Debug.LogError("Git is not set-up correctly, required to be on PATH, and to be a git project.");
            return("git-error");
        }

        // Read the results back from the process so we can get the output and check for errors
        string output      = process.StandardOutput.ReadToEnd();
        string errorOutput = process.StandardError.ReadToEnd();

        process.WaitForExit(); // Make sure we wait till the process has fully finished.
        process.Close();       // Close the process ensuring it frees it resources.

        // Check for fatal errors.
        if (output.IsNullOrEmpty() || output.Contains("fatal"))
        {
            string errorMessage = $"Command failed: git {gitCommand}\n{output}\n{errorOutput}\n";
            if (throwOnFailure)
            {
                throw new BuildFailedException(errorMessage);
            }

            Debug.LogError(errorMessage);
            return("");
        }

        // Log any errors.
        if (!errorOutput.IsNullOrEmpty())
        {
            Debug.LogError("Git Error: " + errorOutput);
        }

        return(output);
    }
コード例 #15
0
 public void Log(int type, string log)
 {
     if (onLog != null)
     {
         onLog(type, log);
     }
     if (type == 1)
     {
         Debug.LogError(log);
     }
 }
コード例 #16
0
 void Awake()
 {
     if (!instance)
     {
         DontDestroyOnLoad(this);
         instance = this;
     }
     else
     {
         Debug.LogError(this.GetType() + "::" + "Awake" + " -- Only one instance of " + this.GetType() + " is allowed at a time");
         Destroy(this.gameObject);
     }
 }
コード例 #17
0
 public LocalizationException(bool firstSceneException)
 {
     if (firstSceneException)
     {
         Debug.LogError("Be sure \n" +
                        "1- You started from the first scene\n" +
                        "2- You placed a localization manager gameobject in the first scene\n" +
                        "3- You placed localization manager script to that gameobject\n" +
                        "4- The localization manager script has singleton called \"Instance\" \n" +
                        "5- That singleton is not destroyed on scene load (check documentary for implementing monobehaviour singletons)."
                        );
     }
 }
コード例 #18
0
    private static bool CopyBuildArtifacts(BuildTarget buildTarget, bool internalSdkBuild, bool debug)
    {
        Debug.Log("Copying MoPub libraries to Unity project");
        var sdkDir = GetSdkSubdir(buildTarget, internalSdkBuild);

        switch (buildTarget)
        {
        case BuildTarget.Android: {
            const string destDir = "Assets/Plugins/Android/mopub/libs";
            // Our wrapper jar.
            var jarDir = debug ? "debug" : "release";
            if (!Cp(GetFullPath("mopub-android-sdk-unity/build/intermediates/bundles/" + jarDir + "/classes.jar"),
                    Path.Combine(destDir, "mopub-unity-plugins.jar")))
            {
                return(false);
            }
            // Platform SDK jars.
            var libCps = from lib in new[] { "base", "banner", "interstitial", "rewardedvideo", "native-static" }
            let src    = string.Format("{0}/mopub-sdk/mopub-sdk-{1}/build/intermediates/bundles/{2}/classes.jar",
                                       sdkDir, lib, jarDir)
                         let dst = string.Format("{0}/mopub-sdk-{1}.jar", destDir, lib)
                                   select Cp(src, dst);

            if (libCps.Contains(false))
            {
                return(false);
            }
            // Copy native ads jar to placeholder directory (as a source for the preference being toggled)
            const string nativeJar = "mopub-sdk-native-static.jar";
            Cp(Path.Combine(destDir, nativeJar), Path.Combine("Assets/MoPub/Extras", nativeJar));
            // Check whether to remove the native ads jar only now, rather than in the loop above, so that it
            // gets removed even if it was present from a prior build.
            return(EditorUserBuildSettings.activeScriptCompilationDefines.Contains(MoPubPreferences.MoPubNativeAdsDefine) ||
                   Rm(Path.Combine(destDir, "mopub-sdk-native-static.jar")));
        }

#if UNITY_EDITOR_OSX
        case BuildTarget.iOS: {
            const string destDir = "Assets/Plugins/iOS";
            var          projDir = GetFullPath("mopub-ios-sdk-unity/bin");
            var          htmlDir = Path.Combine(sdkDir, "MoPubSDK/Resources");
            return(Rsync(projDir, destDir, "*.h", "*.m", "*.mm", "*.framework") &&
                   Rsync(htmlDir, Path.Combine(destDir, "MoPubSDKFramework.framework"), "*.html", "*.png"));
        }
#endif
        default:
            Debug.LogError("Invalid build target: " + buildTarget);
            return(false);
        }
    }
コード例 #19
0
    /// <summary>
    /// +演算の定義
    /// </summary>
    public static Vector operator+(Vector v1, Vector v2)
    {
        if (v1.Size != v2.Size)
        {
            Debug.LogError($"not match size v1 : {v1.Size}, v2 : {v2.Size}");
            return(v1);
        }
        Vector newV = new Vector(v1.Size);

        for (int i = 0; i < v1.Size; i++)
        {
            newV.Values[i] = v1.Values[i] + v2.Values[i];
        }
        return(newV);
    }
コード例 #20
0
    private static string RunCommand(string command)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo("bash")
        {
            WorkingDirectory       = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
            CreateNoWindow         = true,
            ErrorDialog            = true,
            UseShellExecute        = false,
            RedirectStandardInput  = true,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            StandardOutputEncoding = System.Text.UTF8Encoding.UTF8,
            StandardErrorEncoding  = System.Text.UTF8Encoding.UTF8,
            Arguments = "-c \"" + command + " \""
        };

        Process process = new Process
        {
            StartInfo = startInfo
        };

        process.Start();

        process.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs args) {
            Debug.LogError(args.Data);
        };
        process.OutputDataReceived += delegate(object sender, DataReceivedEventArgs args) {
            Debug.LogError(args.Data);
        };
        process.Exited += delegate(object sender, System.EventArgs args) {
            Debug.LogError(args.ToString());
        };

        string line = process.StandardOutput.ReadToEnd();

        if (line != null)
        {
            return(line.Replace("\\", "/"));
        }

        string error = process.StandardError.ReadToEnd();

        if (error != null)
        {
            Debug.LogError(error);
        }
        return(null);
    }
コード例 #21
0
    static void PackAssetBundle()
    {
        Debug.LogError("打包资源 ----- 1");
        var start = DateTime.Now;

        Debug.LogError("打包资源 ----- 2");
        PackageTool.BuildAssetBundlesForCurrentChannel();
        Debug.LogError("打包资源 ----- 3");
        AssetBundleMenuItems.ToolsCopyAssetbundles();
        Debug.LogError("打包资源 ----- 4");
        AssetDatabase.Refresh();
        Debug.LogError("打包资源 ----- 5");
        Debug.LogError($"打包完成\nRunAllCheckres; ExecuteBuild; CopyToStreamingAsset; " +
                       $"使用时长为:{(DateTime.Now - start).TotalSeconds}");
        Debug.LogError("打包资源 ----- 6");
    }
コード例 #22
0
    public static void PackMod(string exportGamePath, bool doDeploy = true)
    {
        string assetPackageInfo = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), GetProjectPath()), "mod.xml").Replace("\\", "/");

        // TODO: get target output shits?
        Debug.Log(assetPackageInfo);
        XDocument parsedModInfo = ParseModXML(assetPackageInfo);

        if (!File.Exists(assetPackageInfo))
        {
            EditorUtility.DisplayDialog("Error!", "The folder does not have 'mod.xml' file!", "Dismiss");
            return;
        }

        if (parsedModInfo != null)
        {
            if (parsedModInfo.Root.Attribute("type") == null)
            {
                Debug.LogError("mod.xml does not have type information!");
                return;
            }

            try {
                ModPackInfo modInfo = new ModPackInfo(parsedModInfo);
                modInfo.BuildAssetBundles();
                modInfo.SwapMaterial();
                modInfo.SetupModFolder();
                if (doDeploy)
                {
                    modInfo.DeployZipMod(exportGamePath);
                    Announce();
                }
                else
                {
                    EditorApplication.Beep();
                }
            } catch (Exception e) {
                Debug.LogError(e);
                SystemSounds.Exclamation.Play();
                EditorUtility.DisplayDialog("Error!", "Failed to build mod!\nCheck the Console!", "Dismiss");
            }
        }
        else
        {
            Debug.LogError("Failed to parse mod information.");
        }
    }
コード例 #23
0
 /// Like LookupIndex<T>(string name) but looks through all the known objects,
 /// as opposed to all the objects with indices.
 public T Lookup <T>(string gltfObjectName) where T : RefObj
 {
     if (!m_nameToObject.TryGetValue(gltfObjectName, out RefObj gltfObj))
     {
         throw new KeyNotFoundException("Missing " + gltfObjectName);
     }
     if (gltfObj is T gltfObjTyped)
     {
         return(gltfObjTyped);
     }
     else
     {
         Type a = typeof(T), b = gltfObj.GetType();
         Debug.LogError($"Two objects are named {gltfObjectName}: T={a} and T={b}");
         throw new KeyNotFoundException("Duplicate " + gltfObjectName);
     }
 }
コード例 #24
0
 /// Returns the specified top-level gltf object.
 /// This may seem like a silly no-op, but it performs some validation
 /// to ensure Lookup(obj) === Lookup<T>(obj.name)
 public RefObj Lookup(RefObj gltfObject)
 {
     if (!m_nameToObject.TryGetValue(gltfObject.name, out RefObj gltfObject2))
     {
         Debug.LogError($"Object {gltfObject.name} was not registered");
         throw new KeyNotFoundException(gltfObject.name);
     }
     if (ReferenceEquals(gltfObject2, gltfObject))
     {
         return(gltfObject);
     }
     else
     {
         Debug.LogError($"Two objects are named {gltfObject.name}: {gltfObject} and {gltfObject2}");
         throw new KeyNotFoundException(gltfObject.name);
     }
 }
コード例 #25
0
ファイル: Command.cs プロジェクト: KubbyDev/BottaGoFast
        //Cherche la commande a laquelle l'ordre fait reference et l'execute
        private static void Execute(string order)
        {
            string[] args              = SeparateFirstArg(order);
            string   commandName       = args[0];
            string   commandParameters = args[1];

            foreach (ReceivableCommand command in receivableCommands)
            {
                if (command.CommandID == commandName)
                {
                    command.ReceiveMethod.Invoke(null, new object[] { commandParameters });
                    return;
                }
            }

            Debug.LogError("Couldn't find command " + commandName);
        }
コード例 #26
0
ファイル: Util.cs プロジェクト: svermeulen/GlobalGameJam2013
    private static void TriggerAssert(string message)
    {
        var myTrace = new StackTrace(true);
        var myFrame = myTrace.GetFrame(2);

        var assertMsg = "Assert Hit! \n\n" + message + "\n\n" + "Filename: " + myFrame.GetFileName() + "\nMethod: " + myFrame.GetMethod() +
                        "\nLine: " + myFrame.GetFileLineNumber();

#if UNITY_EDITOR
        switch (_handleMethod)
        {
        case AssertHandleMethod.LogAndContinue:
            Debug.LogError(assertMsg);
            break;

        case AssertHandleMethod.MessageBox:

            if (!_shouldStop)
            {
                var choice = EditorUtility.DisplayDialogComplex("Assert Hit!", assertMsg,
                                                                "Go To", "Ignore", "Stop");

                Debug.LogError(assertMsg);
                if (choice == 0 || choice == 2)
                {
                    EditorApplication.isPlaying = false;
                    _shouldStop = true;
                }

                if (choice == 0)
                {
                    InternalEditorUtility.OpenFileAtLineExternal(myFrame.GetFileName(), myFrame.GetFileLineNumber());
                }
            }

            break;

        case AssertHandleMethod.Exception:
            throw new AssertException(assertMsg);

        default:
            Util.Assert(false);
            break;
        }
#endif
    }
コード例 #27
0
ファイル: WayPoint.cs プロジェクト: zanzo420/Sci-Fi_Rougelike
    public int CompareTo(object obj)
    {
        if (obj == null)
        {
            return(1);
        }

        var other = obj as WayPoint;

        if (other != null)
        {
            return(Potential.CompareTo(other.Potential));
        }

        Debug.LogError("Cant compare a WayPoint to a non WayPoint");
        return(0);
    }
コード例 #28
0
    // Build the platform MoPub SDK using its native build system.
    private static bool BuildPlatformSdk(BuildTarget buildTarget, bool internalSdkBuild, bool debug)
    {
        Debug.LogFormat("Building MoPub platform SDK for {0} (internal: {1}, debug: {2})", buildTarget, internalSdkBuild, debug);
        switch (buildTarget)
        {
        case BuildTarget.Android:
#if UNITY_EDITOR_OSX
            const string cmd     = "bash";
            const string gradlew = "gradlew";
#elif UNITY_EDITOR_WIN
            const string cmd     = "cmd";
            const string gradlew = "/c gradlew.bat";
#endif
            var sdkDir = GetSdkSubdir(buildTarget, internalSdkBuild);
            return(Run(cmd, string.Format("{0} clean assemble{1}", gradlew, debug ? "Debug" : "Release"),
                       GetFullPath("mopub-android-sdk-unity"),
                       "SDK_DIR=" + Path.GetFileName(sdkDir),
                       "ANDROID_HOME=" + EditorPrefs.GetString("AndroidSdkRoot")));

#if UNITY_EDITOR_OSX
        case BuildTarget.iOS:
            var project = "mopub-ios-sdk-unity.xcodeproj";
            if (internalSdkBuild)
            {
                project = "internal-" + project;
            }
            var jsfile = GetFullPath("mopub-ios-sdk-unity/bin/MoPubSDKFramework.framework/MRAID.bundle/mraid.js");
            return(Run("xcrun",
                       "xcodebuild"
                       + " -project " + project
                       + " -scheme \"MoPub for Unity\""
                       + " -configuration \"" + (debug ? "Debug" : "Release") + "\""
                       + " OTHER_CFLAGS=\"-fembed-bitcode -w\""
                       + " BITCODE_GENERATION_MODE=bitcode"
                       + " clean build",
                       GetFullPath("mopub-ios-sdk-unity"))
                   // Have to rename the .js file inside the framework so that Unity doesn't try to compile it...
                   // This rename is reverted in the MoPubPostBuildiOS script during an app build.
                   && Mv(jsfile, jsfile + ".prevent_unity_compilation"));
#endif
        default:
            Debug.LogError("Invalid build target: " + buildTarget);
            return(false);
        }
    }
コード例 #29
0
    public static void BuildGame()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        var buildScenes = new List <string>();
        var allScenes   = EditorBuildSettings.scenes;

        foreach (var scene in allScenes)
        {
            if (scene.enabled)
            {
                var importer = AssetImporter.GetAtPath(scene.path);
                if (importer != null && string.IsNullOrEmpty(importer.assetBundleName))
                {
                    buildScenes.Add(scene.path);
                }
            }
        }

        buildPlayerOptions.scenes = buildScenes.ToArray();
        string dir = EditorUtility.OpenFolderPanel("BuildApp", "", "");

        if (string.IsNullOrEmpty(dir))
        {
            Debug.LogError("选中Build目录为空");
            return;
        }

        Debug.Log("BuildGameApp:" + dir);
        string appName = "";

        if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
        {
            appName = "game_" + DateTime.Now.ToString("yyyy_MM_dd-HH_mm_ss") + ".apk";
            buildPlayerOptions.locationPathName = dir + "/" + appName;
        }
        else
        {
            buildPlayerOptions.locationPathName = dir;
        }
        buildPlayerOptions.target  = EditorUserBuildSettings.activeBuildTarget;
        buildPlayerOptions.options = BuildOptions.None;
        BuildPipeline.BuildPlayer(buildPlayerOptions);

        Process.Start(dir);
    }
コード例 #30
0
    //---------------------------------------------------------------------------

    #endregion

    //---------------------------------------------------------------------------

    #region Public Member Functions

    //---------------------------------------------------------------------------

    /// <summary>
    /// Raises the enable event when OCLogger is loaded.  Initialized here.
    /// </summary>
    public void OnEnable()
    {
        LogLevel logLevel = LogLevel.NONE;

        try
        {
            logLevel = (LogLevel)
                       Enum.Parse(typeof(LogLevel), OCConfig.Instance.get("LOG_LEVEL"));
        }
        catch (ArgumentException ae)
        {
            Debug.LogError
                ("In OCLogger.OnEnable: Failed to construct [" + ae.Message + "]");
        }
        CurrentLevel = logLevel;

        IsLogEnabled = logLevel > LogLevel.NONE;
    }