Log() public static method

public static Log ( object msg ) : void
msg object
return void
コード例 #1
0
    public void RpcResultInvest()
    {
        var suminvest = 0;
        var curbuild  = GM.Buildings[GM.LandNum];

        for (int i = 0; i < 6; i++)
        {
            suminvest += GM.invest[i];
        }

        if (suminvest >= curbuild.building.getMinPopulation())
        {
            InGameSoundManager.SEinvestSuccess.Play();
            if (curbuild.building.getState() == State.Idle)
            {
                curbuild.building.setState(State.Constructing);
                //GM.RpcLogAddedEventInvoke($"\t건물 건설이 성사되었습니다.");
                if (isServer)
                {
                    GM.RpcLog($"[{curbuild.gameObject.name}]건물 건설이 성사되었습니다.");
                }
                //GM.LM.CmdOnLogReceivedEvent($"[{curbuild.gameObject.name}]건물 건설이 성사되었습니다.");
            }
            else if (curbuild.building.getState() == State.Damaged)
            {
                curbuild.building.setState(State.Repair);
                //GM.RpcLogAddedEventInvoke($"\t건물 건설이 무산되었습니다.");
                if (isServer)
                {
                    GM.RpcLog($"[{curbuild.gameObject.name}]건물 수리가 성사되었습니다.");
                }
                //GM.LM.CmdOnLogReceivedEvent($"[{curbuild.gameObject.name}]건물 수리가 성사되었습니다.");
            }
            curbuild.building.setCompleteTurn((int)Mathf.Ceil(curbuild.building.getNeedPopulation() / suminvest));
            if (curbuild.building.getCompleteTurn() < 1)
            {
                curbuild.building.setCompleteTurn(1);
                Debug.Log("Turn을 1로 변경함.");
            }

            for (int i = 0; i < 6; i++)
            {
                if (GM.AlienDistribution[i] == true)
                {
                    curbuild.building.setAlien(curbuild.building.getAlien() + GM.invest[i]);
                }
                else
                {
                    curbuild.building.setHuman(curbuild.building.getHuman() + GM.invest[i]);
                }
            }
            curbuild.ShowBuildingStateImage();
        }
        else
        {
            if (isServer)
            {
                GM.RpcLog($"[{curbuild.gameObject.name}]건물 건설이 무산되었습니다.");
            }
            //GM.LM.CmdOnLogReceivedEvent($"[{curbuild.gameObject.name}]건물 건설이 무산되었습니다.");
            InGameSoundManager.SEinvestFail.Play();
        }

        for (int i = 0; i < 6; i++)
        {
            GM.invest[i] = 0;
        }
    }
コード例 #2
0
 public void TestRichText()
 {
     Debug.Log(
         "<b>Rich text</b> is <i>supported</i> in the <b><i>console</i></b>. <color=#7fc97a>Color tags, too!</color>");
 }
コード例 #3
0
    public override void AskToMakeFile(string speechText, string speakerName, string fullFileName, string fileFormat)
    {
        Process makeFileRequest = new Process();


        // Unity Webplayer Mono doesn't support this:
        // Process.StartInfo is read-only

        //ProcessStartInfo startInfo = new ProcessStartInfo();

        ////if (Application.platform == RuntimePlatform.WindowsPlayer)
        ////    startInfo.FileName = Application.dataPath + @"/Easy Voice/Apps/EasyVoiceMacTerminalSpoof.exe";
        ////else
        //    startInfo.FileName = @"/usr/bin/say";
        //startInfo.Arguments =
        //    (speakerName != "" ? " -v \"" + speakerName.Replace("\"", "\"\"") + "\"" : "") +
        //    " -o \"" + fullFileName.Replace("\"", "\"\"") + "\"" +
        //    (fileFormat != "" ? " --file-format=" + fileFormat : "") + // AIFF explicit, not via .aiff, only one that works
        //    " \"" + speechText.Replace("\"", "\"\"") + "\"";
        //startInfo.CreateNoWindow = true;
        //startInfo.RedirectStandardOutput = true; // we need to capture it
        //startInfo.RedirectStandardError = true; // we need to capture it
        //startInfo.UseShellExecute = false; // must be false for redirect output

        //makeFileRequest.StartInfo = startInfo;


        //if (Application.platform == RuntimePlatform.WindowsPlayer)
        //    startInfo.FileName = Application.dataPath + @"/Easy Voice/Apps/EasyVoiceMacTerminalSpoof.exe";
        //else
        makeFileRequest.StartInfo.FileName  = @"/usr/bin/say";
        makeFileRequest.StartInfo.Arguments =
            (speakerName != "" ? " -v \"" + speakerName.Replace("\"", "\"\"") + "\"" : "") +
            " -o \"" + fullFileName.Replace("\"", "\"\"") + "\"" +
            (fileFormat != "" ? " --file-format=" + fileFormat : "") + // AIFF explicit, not via .aiff, only one that works
            " \"" + speechText.Replace("\"", "\"\"") + "\"";
        makeFileRequest.StartInfo.CreateNoWindow         = true;
        makeFileRequest.StartInfo.RedirectStandardOutput = true;  // we need to capture it
        makeFileRequest.StartInfo.RedirectStandardError  = true;  // we need to capture it
        makeFileRequest.StartInfo.UseShellExecute        = false; // must be false for redirect output

#if DEBUG_MESSAGES
        Debug.Log("Starting query...");
#endif

        makeFileRequest.Start();

        makeFileRequest.WaitForExit();

        if (makeFileRequest.ExitCode == 0)
        {
            using (StreamReader streamReader = makeFileRequest.StandardOutput)
            {
            }
        }
        else
        {
            using (StreamReader streamReader = makeFileRequest.StandardError)
            {
                string result = streamReader.ReadToEnd();
                Debug.LogError("Process error: " + result);
            }
        }

#if USE_CLOSE
        makeFileRequest.Close();
#endif
    }
コード例 #4
0
 public static void Log(string msg)
 {
     Debug.Log(msg);
 }
コード例 #5
0
 private void OnValueChanged(string n, object newValue)
 {
     Debug.Log("[SRDebug] {0} value changed to {1}".Fmt(n, newValue));
     OnPropertyChanged(n);
 }
コード例 #6
0
 private static void BuildConfigMenu()
 {
     Debug.Log("Building worker configs...");
     EditorApplication.delayCall += BuildConfig;
 }
コード例 #7
0
 private static void LaunchStandaloneClient()
 {
     Debug.Log("Launching a standalone client");
     EditorApplication.delayCall += LaunchClient;
 }
コード例 #8
0
    public static void MinifyJsCode(bool displayDialog)
    {
        var jsFiles = GetNeedMinifyJsFiles();

        if (displayDialog)
        {
            if (!EditorUtility.DisplayDialog("TIP",
                                             "Total: " + jsFiles.Count + "个Js文件进行Minify",
                                             "OK",
                                             "Cancel"))
            {
                Debug.Log("Operation canceled.");
                return;
            }
        }


        string workingDir = Application.dataPath.Replace("/Assets", "");

#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, "JSBExternalTools/closure-compiler/minifyJs.bat");
        string arguments = String.Join(" ", jsFiles.ToArray());
#else
        string exePath   = "/bin/bash";
        string arguments = Path.Combine(workingDir, "JSBExternalTools/closure-compiler/minifyJs.sh") + " " + string.Join(" ", jsFiles.ToArray());
#endif
        //这里要使用UseShellExecute的方式执行批处理脚本,重定向输出信息的话,会导致Unity卡死
        //暂不知道原因可能是Java程序没执行完毕
        var processInfo = new ProcessStartInfo
        {
#if USE_SHELL
            CreateNoWindow         = true,
            UseShellExecute        = true,
            RedirectStandardOutput = false,
            RedirectStandardError  = false,
            FileName  = exePath,
            Arguments = arguments
#else
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
#endif
        };

        var process = Process.Start(processInfo);
#if !USE_SHELL
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
#endif
        // 等待结束
        process.WaitForExit();

        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            if (displayDialog)
            {
                EditorUtility.DisplayDialog("JsMinify", "Minify failed. exit code = " + exitCode, "OK");
            }
#if !USE_SHELL
            if (!string.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }
#endif
        }
        else
        {
            if (displayDialog)
            {
                EditorUtility.DisplayDialog("JsMinify", "JsCode Minify success.", "OK");
            }
        }

        //输出Minify日志
#if !USE_SHELL
        string logFile = GetTempFileNameFullPath("minify_log.txt");
        File.WriteAllText(logFile, outputLog);
        Debug.LogError(outputLog);

        string relPath = logFile.Replace("\\", "/").Substring(logFile.IndexOf("Assets/"));
        var    context = AssetDatabase.LoadAssetAtPath <Object>(relPath);
        Debug.Log("生成了文件 " + relPath + ",请检查(点击此条可定位文件)", context);
#endif
        AssetDatabase.Refresh();
    }
コード例 #9
0
ファイル: Assets.cs プロジェクト: zhangkj/xasset
 private static void Log(string s)
 {
     Debug.Log(string.Format("[Assets]{0}", s));
 }
コード例 #10
0
    public static void GenerateJsTypeInfo(bool displayDialog)
    {
        var    fileInfoSb = new StringBuilder();
        string workingDir = Application.dataPath.Replace("/Assets", "");
        var    args       = new args();

        // working dir
        args.AddFormat("/dir:\"{0}\"", workingDir);
        args.AddFormat("/out:\"{0}\"", JsTypeInfoFile);
        args.AddFormat("/template:\"{0}\"", JsTypeInfoFileTemplate);
        args.AddFormat("/format:\"{0}\"", JsTypeFormat);

        var exportList  = GetExportFiles();
        var exportCount = exportList.Count;

        foreach (var filePath in exportList)
        {
            fileInfoSb.AppendLine(filePath.Replace(Application.dataPath, ""));
            args.Add("\"" + filePath.Replace(workingDir, ".") + "\"");
        }

        // 把参数写到文件中,然后把这个文件路径做为参数传递给 skc5.exe
        string argFile = GetTempFileNameFullPath("JsTypeGenerator_Args.txt");
        string strArgs = args.Format(args.ArgsFormat.Space);

        File.WriteAllText(argFile, strArgs);

        string addTypeInfoFile = GetTempFileNameFullPath(FilesToAddJsType);

        File.WriteAllText(addTypeInfoFile, fileInfoSb.ToString());
        AssetDatabase.Refresh();

        if (displayDialog)
        {
            if (!EditorUtility.DisplayDialog("TIP",
                                             "Total: " + exportCount + "file prepare to Add [JsType]",
                                             "OK",
                                             "Cancel"))
            {
                Debug.Log("Operation canceled.");
                return;
            }
        }

#if UNITY_EDITOR_WIN
        string exePath   = Path.Combine(workingDir, JsTypeGeneratorPath);
        string arguments = String.Format("/paramFile:\"{0}\"", argFile);
#else
        string exePath   = "/usr/local/bin/mono";
        string arguments = Path.Combine(workingDir, JsTypeGeneratorPath) + string.Format(" /paramFile:\"{0}\"", argFile);
#endif
        var processInfo = new ProcessStartInfo
        {
            CreateNoWindow         = true,
            UseShellExecute        = false,
            RedirectStandardOutput = true,
            RedirectStandardError  = true,
            FileName  = exePath,
            Arguments = arguments
        };

        var    process   = Process.Start(processInfo);
        string outputLog = process.StandardOutput.ReadToEnd();
        string errorLog  = process.StandardError.ReadToEnd();
        // 等待结束
        process.WaitForExit();

        Debug.LogError(outputLog);
        int exitCode = process.ExitCode;
        process.Close();
        if (exitCode != 0)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "Generate failed. exit code = " + exitCode, "OK");
            if (!String.IsNullOrEmpty(errorLog))
            {
                Debug.LogError(errorLog);
            }
            throw new SystemException(errorLog);
        }

        //每次生成JsTypeInfo,清空一下JsTypeNameSet
        _jsTypeNameSet = null;
        if (displayDialog)
        {
            EditorUtility.DisplayDialog("JsTypeGenerator", "GenerateJsTypeInfo success.", "OK");
        }

        // 刷新前改一下文件格式,减少编译时间
        EditorHelper.SetFileFormatToUTF8_BOM(JsTypeInfoFile);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
コード例 #11
0
    private static void CheckError_Invocation(string allInvokeWithLocationOutputPath)
    {
        if (typesImpByJs == null)
        {
            typesImpByJs      = new Dictionary <string, List <string> >();
            typesImpByJs["T"] = new List <string> {
                "T"
            };
            typesImpByJs["System.Action"] = new List <string> {
                ""                                                /* 调用 action */
            };
            typesImpByJs["System.Action$1"] = new List <string> {
                ""                                                  /* 调用 action */
            };
            typesImpByJs["System.Action$2"] = new List <string> {
                ""                                                  /* 调用 action */
            };
            typesImpByJs["System.Action$3"] = new List <string> {
                ""                                                  /* 调用 action */
            };
            typesImpByJs["System.Action$4"] = new List <string> {
                ""                                                  /* 调用 action */
            };
            typesImpByJs["System.Func$1"] = new List <string> {
                ""                                                /* 调用 action */
            };
            typesImpByJs["System.Func$2"] = new List <string> {
                ""                                                /* 调用 action */
            };
            typesImpByJs["System.Func$3"] = new List <string> {
                ""                                                /* 调用 action */
            };
            typesImpByJs["System.Func$4"] = new List <string> {
                ""                                                /* 调用 action */
            };
            typesImpByJs["System.Exception"] = new List <string> {
                "ctor$$String"
            };
            typesImpByJs["System.NotImplementedException"] = new List <string> {
                "ctor"
            };
            typesImpByJs["System.Array"] = new List <string>
            {
                "length",
                "CopyTo",
                "Static_Convertall",
                "Static_Sort$1$$T$Array"
            };
            typesImpByJs["System.Collections.Generic.List$1"] = new List <string>
            {
                "ctor",
                "ctor$$IEnumerable$1",
                "ctor$$Int32",
                "RemoveRange",
                "Clear",
                "get_Item$$Int32",
                "set_Item$$Int32",
                "get_Count",
                "GetEnumerator",
                "ToArray",
                "AddRange",
                "Add",
                "Remove",
                "Contains",
                "SetItems",
                "IndexOf",
                "Exists",
                "IndexOf$$T",
                "Insert",
                "RemoveAt",
                "RemoveAll",
                //"TryRemove",
                "CopyTo",
                //"get_IsReadOnly",
                "Reverse",
                "Sort",
                "Sort$$Comparison$1",
                "ForEach",
                "Find",
                "FindIndex$$Predicate$1",
                "FindIndex$$Int32$$Predicate$1",
                "FindIndex$$Int32$$Int32$$Predicate$1",
                "FindLastIndex$$Predicate$1",
                "FindLastIndex$$Int32$$Predicate$1",
                "FindLastIndex$$Int32$$Int32$$Predicate$1",
                "FindAll",
                "GetRange",
                "InsertRange"
            };
            typesImpByJs["System.Collections.Generic.Dictionary$2"] = new List <string>
            {
                "ctor",
                "ctor$$Int32",
                "Add",
                "Remove",
                "get_Item$$TKey",
                "set_Item$$TKey",
                "ContainsKey",
                "GetEnumerator",
                "Clear",
                "TryGetValue",
                "get_Count",
                "get_Keys",
                "get_Values"
            };
            typesImpByJs["System.Collections.Generic.KeyValuePair$2"] = new List <string>
            {
                "get_Key",
                "get_Value",
                "ctor$$TKey$$TValue"
            };
            typesImpByJs["System.Collections.Generic.Dictionary.ValueCollection$2"] = new List <string> {
                "CopyTo"
            };
            // 特殊!
            typesImpByJs["System.Collections.Generic.Dictionary.KeyCollection$2"] = new List <string> {
                "CopyTo"
            };                                                                                                     // 特殊!
            typesImpByJs["System.Linq.Enumerable"] = new List <string> {
                "Static_ToArray$1"
            };
            typesImpByJs["System.Collections.Generic.HashSet$1"] = new List <string>
            {
                "ctor",
                "Add",
                "get_Count",
                "Clear",
                "Contains",
                "Remove"
            };
            typesImpByJs["System.Collections.Generic.Queue$1"] = new List <string>
            {
                "ctor",
                "ctor$$Int32",
                "Clear",
                "get_Count",
                "Enqueue",
                "Dequeue",
                "Peek",
                "Contains",
                "ToArray"
            };
            typesImpByJs["System.String"] = new List <string>
            {
                // native
                "toString",
                "length",
                "replace",
                "split",
                "indexOf",
                "substr",
                "charAt",
                /// static
                "Static_Empty",
                "Static_Format$$String$$Object",
                "Static_Format$$String$$Object$$Object",
                "Static_Format$$String$$Object$$Object$$Object",
                "Static_IsNullOrEmpty",
                "Static_Equals$$String$$String$$StringComparison",
                "Static_Join$$String$$String$Array",
                // instance
                "ctor$$Char$Array",
                "ctor$$Char$Array$$Int32$$Int32",
                "Insert",
                "Substring$$Int32",
                "Substring$$Int32$$Int32",
                "Substring",
                "ToLower",
                "toLowerCase",
                "ToUpper",
                "toUpperCase",
                "getItem",
                "IndexOf$$String",
                "IndexOf$$Char",
                "LastIndexOf",
                "LastIndexOf$$Char",
                "LastIndexOf$$String",
                "Remove$$Int32",
                "Remove$$Int32$$Int32",
                "StartsWith$$String",
                "EndsWith$$String",
                "Contains",
                "get_Length",
                "Split$$Char$Array",
                "trim",
                "Trim",
                "ltrim",
                "rtrim",
                "Static_Format$$String$$Object$Array",
                "Replace$$String$$String",
                "Replace$$Char$$Char",
                "PadLeft$$Int32$$Char",
                "PadRight$$Int32$$Char",
                "ToCharArray"
            };
            typesImpByJs["System.Char"] = new List <string> {
                "toString", "Static_IsNumber$$Char"
            };
            typesImpByJs["System.Int32"] = new List <string>
            {
                "toString",
                "Static_Parse$$String",
                "Static_TryParse$$String$$Int32",
                "ToString$$String",
                "CompareTo$$Int32"
            };
            typesImpByJs["System.UInt64"] = new List <string>
            {
                "toString",
                "Static_Parse$$String",
                "Static_TryParse$$String$$UInt64"
            };
            typesImpByJs["System.Int64"] = new List <string>
            {
                "toString",
                "Static_Parse$$String",
                "Static_TryParse$$String$$Int64",
                "ToString$$String",
                "CompareTo$$Int64"
            };
            typesImpByJs["System.Boolean"] = new List <string>
            {
                "toString",
                "CompareTo$$Boolean"
            };
            typesImpByJs["System.Double"] = new List <string>
            {
                "toString",
                "ToString$$String",
                "CompareTo$$Double",
                "Static_tryParse",
                "Static_Parse$$String",
                "Static_TryParse$$String$$Double"
            };
            typesImpByJs["System.Single"] = new List <string>
            {
                "toString",
                "ToString$$String",
                "CompareTo$$Single",
                "Static_tryParse",
                "Static_Parse$$String",
                "Static_TryParse$$String$$Single"
            };
            //			typesImpByJs["System.Int32"] = new List<string> { "toString", "Static_Parse$$String",  };
            typesImpByJs["System.Enum"] = new List <string> {
                "toString"
            };
            typesImpByJs["System.MulticastDelegate"] = new List <string>();
        }


        string allExportedMembersFile = GetAllExportedMembersFile();

        var allInvoked  = LoadAllInvoked(allInvokeWithLocationOutputPath);
        var allExported = LoadAllExported(allExportedMembersFile);

        foreach (var KV in typesImpByJs)
        {
            HashSet <string> HS = null;
            if (!allExported.TryGetValue(KV.Key, out HS))
            {
                HS = new HashSet <string>();
                allExported.Add(KV.Key, HS);
            }
            if (KV.Value == null)
            {
                continue;
            }

            foreach (string m in KV.Value)
            {
                if (!HS.Contains(m))
                {
                    HS.Add(m);
                }
            }
        }

        var sbError = new StringBuilder();

        int errCount = 0;

        foreach (var KV in allInvoked)
        {
            string           typeName = KV.Key;
            HashSet <string> hsExported;
            var DInvoked = KV.Value;

            // 类有导出吗?
            if (!allExported.TryGetValue(typeName, out hsExported))
            {
                errCount++;
                sbError.AppendFormat("[{0}] not exported.", typeName);
                sbError.AppendLine();
                foreach (var KV2 in DInvoked)
                {
                    string methodName = KV2.Key;
                    sbError.AppendFormat("      {0}", methodName);
                    sbError.AppendLine();

                    foreach (var loc in KV2.Value)
                    {
                        sbError.AppendFormat("        {0} {1}", loc.FileName, loc.Line);
                        sbError.AppendLine();
                    }
                }
            }
            else
            {
                foreach (var KV2 in DInvoked)
                {
                    string methodName = KV2.Key;
                    // 函数可用/有导出吗
                    if (hsExported == null || !hsExported.Contains(methodName))
                    {
                        errCount++;
                        sbError.AppendFormat("[{0}].{1} not valid.", typeName, methodName);
                        sbError.AppendLine();

                        foreach (var loc in KV2.Value)
                        {
                            sbError.AppendFormat("        {0} {1}", loc.FileName, loc.Line);
                            sbError.AppendLine();
                        }
                    }
                }
            }
        }

        string fullpath = GetTempFileNameFullPath("CompilerCheckErrorResult.txt");

        File.Delete(fullpath);

        if (errCount > 0)
        {
            File.WriteAllText(fullpath, sbError.ToString());

            string relPath = fullpath.Replace("\\", "/").Substring(fullpath.IndexOf("Assets/"));
            var    context = AssetDatabase.LoadAssetAtPath <Object>(relPath);
            Debug.LogError("Check invocation error result: (" + errCount + " errors) (点击此条可定位文件)", context);
            Debug.LogError(sbError);
        }
        else
        {
            Debug.Log("Check invocation error result: 0 error");
        }
    }
コード例 #12
0
        private IEnumerator ProcessTestQueue()
        {
            Debug.LogFormat("[PlayModeTestRunner] ProcessTestQueueProcess: Mode {0}", RunTestsMode.Mode);

            ClassNode previousClassNode = null;

            ITestRunnerCallbackReceiver[] callbackables = TriggerBeforeTestRunEvent(Callbackables);

            List <MethodNode> methods = null;

            if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.DoubleClick)
            {
                if (!string.IsNullOrEmpty(RunTestsMode.NodeToRunFullName))
                {
                    var targetNodes =
                        TestsRootNode.GetChildrenOfType <Node>(true, false,
                                                               node =>
                    {
                        return(node.FullName.Equals(RunTestsMode.NodeToRunFullName, StringComparison.Ordinal));
                    });

                    if (targetNodes.Count > 0)
                    {
                        var targetNode = targetNodes[0];
                        if (targetNode is MethodNode)
                        {
                            methods = new List <MethodNode>
                            {
                                (MethodNode)targetNode
                            };
                        }
                        else
                        {
                            methods = targetNode.GetChildrenOfType <MethodNode>();
                        }
                    }
                }
            }

            if (methods == null || methods.Count == 0)
            {
                methods = TestsRootNode.GetChildrenOfType <MethodNode>();
            }

            Debug.LogFormat("[PlayModeTestRunner] NonFilteredMethods: {0}", methods.Count);

            methods = methods.Where(methodNode =>
            {
                Debug.LogFormat("method data: IsSmoke: {0}  isSelected: {1}",
                                methodNode.TestSettings.IsSmoke,
                                methodNode.IsSelected);

                if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.Smoke &&
                    !methodNode.TestSettings.IsSmoke)
                {
                    return(false);
                }

                if (RunTestsMode.Mode == RunTestsMode.RunTestsModeEnum.Selected &&
                    !methodNode.IsSelected)
                {
                    return(false);
                }

                if (Namespaces != null && Namespaces.Length > 0)
                {
                    var result = false;

                    for (int i = 0; i < Namespaces.Length; i++)
                    {
                        var contains = methodNode.FullName.IndexOf(Namespaces[i],
                                                                   StringComparison.OrdinalIgnoreCase) != -1;
                        result |= contains;
                    }

                    return(result);
                }

                return(true);
            }).ToList();

            Debug.LogFormat("[PlayModeTestRunner] FilteredMethods: {0}", methods.Count);

            testInfoData.Total = methods.Count;
            for (int i = 0; i < methods.Count; i++)
            {
                var methodNode = methods[i];
                TestStep.Reset();
                ClassNode classNode = (ClassNode)methodNode.Parent;

                Debug.Log("QA: Process " + classNode.Type + " testClass.TestMethods #: " + classNode.Children.Count());
                CurrentPlayingMethodNode.UpdateCurrentPlayingNode(methodNode);
                playModeLogger.Logs.Clear();
                if (methodNode.TestSettings.IsIgnored)
                {
                    ProcessIgnore(methodNode);
                    continue;
                }

                for (int repeatTime = 0; repeatTime < RunTestsGivenAmountOfTimes; repeatTime++)
                {
                    exceptionThrown = false;
#if UNITY_EDITOR
                    if (methodNode.TestSettings.EditorTargetResolution != null)
                    {
                        CustomResolution resolution = methodNode.TestSettings.EditorTargetResolution;

                        if (resolution.Width != Screen.width ||
                            resolution.Height != Screen.height)
                        {
                            GameViewResizer.SetResolution(resolution.Width, resolution.Height);
                        }
                    }
#endif

                    if (!methodNode.TestSettings.ContainsTargetResolution(Screen.width, Screen.height))
                    {
#if UNITY_EDITOR
                        if (methodNode.TestSettings.EditorTargetResolution == null)
                        {
                            Debug.LogWarning(String.Format("PlayModeTestRunner: TARGET RESOLUTION {0}:{1}",
                                                           methodNode.TestSettings.DefaultTargetResolution.Width,
                                                           methodNode.TestSettings.DefaultTargetResolution.Height));

                            GameViewResizer.SetResolution(methodNode.TestSettings.DefaultTargetResolution.Width,
                                                          methodNode.TestSettings.DefaultTargetResolution.Height);
                        }
#else
                        ProcessIgnore(methodNode);
                        continue;
#endif
                    }

                    object testInstance = null;
                    screenGUIDrawer.SetCurrentTest(methodNode.FullName);
                    playModeLogger.StartLog(methodNode.FullName);

                    try
                    {
                        testInstance = Activator.CreateInstance(classNode.Type);
                    }
                    catch (Exception ex)
                    {
                        if (classNode.Type == null)
                        {
                            Debug.LogErrorFormat("Can't instantiate class - class type is null." +
                                                 " class probably was deleted ");
                        }
                        else
                        {
                            Debug.LogErrorFormat("Can't instantiate class \"{0}\". Exception: \"{1}\"",
                                                 classNode.Type.FullName, ex.Message);
                        }

                        ProcessTestFail(methodNode);
                        continue;
                    }

                    Time.timeScale = DefaultTimescale;
                    Debug.Log("QA: Running testClass: " + classNode.Type);

                    if (classNode != previousClassNode)
                    {
                        previousClassNode = classNode;

                        yield return(RunMethods(classNode.OneTimeSetUpMethods, testInstance, true));

                        if (exceptionThrown)
                        {
                            Debug.LogError("Fail during executing set up methods.");
                            ProcessTestFail(methodNode);
                            continue;
                        }
                    }

                    yield return(RunMethods(classNode.SetUpMethods, testInstance, true));

                    if (exceptionThrown)
                    {
                        Debug.LogError("Fail during executing set up methods.");
                        ProcessTestFail(methodNode);
                        continue;
                    }

                    yield return(InvokeTestMethod(testInstance, methodNode));

                    var exceptionDuringTestMethod = exceptionThrown;
                    exceptionThrown = false;

                    yield return(RunMethods(classNode.TearDownMethods, testInstance, false));

                    if (i + 1 == methods.Count ||
                        methods[i + 1].Parent != classNode)
                    {
                        yield return(RunMethods(classNode.OneTimeTearDownMethods, testInstance, true));
                    }

                    if (!exceptionDuringTestMethod && exceptionThrown)
                    {
                        Debug.LogError("Fail during executing tear down methods.");
                        ProcessTestFail(methodNode);
                        continue;
                    }

                    if (exceptionDuringTestMethod)
                    {
                        ProcessTestFail(methodNode);
                        continue;
                    }

                    testInfoData.AddSuccess(methodNode.FullName);
                    playModeLogger.EndLog(methodNode.FullName);
                    methodNode.SetTestState(TestState.Passed);
                    methodNode.Logs = playModeLogger.LogsCopy;
                    methodNode.SetStep(TestStep.CurrentIndex);

                    if (OnMethodStateUpdated != null)
                    {
                        OnMethodStateUpdated();
                    }
                }
            }

            TriggerAfterTestRunEvent(callbackables);

            FinalizeTest();
        }
コード例 #13
0
ファイル: Bundles.cs プロジェクト: hafewa/emo
 private static void Log(string s)
 {
     Debug.Log("[Bundles]" + s);
 }
コード例 #14
0
    /// <remarks>
    /// Affected by frame-rate of app, as this Coroutine checks the socket for a result once per frame.
    /// </remarks>
    public IEnumerator PingSocket(Region region)
    {
        region.Ping = Attempts * MaxMilliseconsPerPing;

        this.PingsRunning++; // TODO: Add try-catch to make sure the PingsRunning are reduced at the end and that the lib does not crash the app
        PhotonPing ping;

        if (PhotonHandler.PingImplementation == typeof(PingNativeDynamic))
        {
            Debug.Log("Using constructor for new PingNativeDynamic()"); // it seems on Android, the Activator can't find the default Constructor
            ping = new PingNativeDynamic();
        }
        else if (PhotonHandler.PingImplementation == typeof(PingNativeStatic))
        {
            Debug.Log("Using constructor for new PingNativeStatic()"); // it seems on Switch, the Activator can't find the default Constructor
            ping = new PingNativeStatic();
        }
        else if (PhotonHandler.PingImplementation == typeof(PingMono))
        {
            ping = new PingMono(); // using this type explicitly saves it from IL2CPP bytecode stripping
        }
        #if UNITY_WEBGL
        else if (PhotonHandler.PingImplementation == typeof(PingHttp))
        {
            ping = new PingHttp();
        }
        #endif
        else
        {
            ping = (PhotonPing)Activator.CreateInstance(PhotonHandler.PingImplementation);
        }

        //Debug.Log(region);

        float rttSum     = 0.0f;
        int   replyCount = 0;

        // all addresses for Photon region servers will contain a :port ending. this needs to be removed first.
        // PhotonPing.StartPing() requires a plain (IP) address without port or protocol-prefix (on all but Windows 8.1 and WebGL platforms).

        string regionAddress = region.HostAndPort;
        int    indexOfColon  = regionAddress.LastIndexOf(':');
        if (indexOfColon > 1)
        {
            regionAddress = regionAddress.Substring(0, indexOfColon);
        }

        // we also need to remove the protocol or Dns.GetHostAddresses(hostName) will throw an exception
        // This is for xBox One for example.
        int indexOfProtocol = regionAddress.IndexOf(PhotonPingManager.wssProtocolString);
        if (indexOfProtocol > -1)
        {
            regionAddress = regionAddress.Substring(indexOfProtocol + PhotonPingManager.wssProtocolString.Length);
        }
        regionAddress = ResolveHost(regionAddress);

        Debug.Log("Ping Debug - PhotonHandler.PingImplementation: " + PhotonHandler.PingImplementation + " ping.GetType():" + ping.GetType() + " regionAddress:" + regionAddress);
        for (int i = 0; i < Attempts; i++)
        {
            bool      overtime = false;
            Stopwatch sw       = new Stopwatch();
            sw.Start();

            try
            {
                ping.StartPing(regionAddress);
            }
            catch (Exception e)
            {
                Debug.Log("catched: " + e);
                this.PingsRunning--;
                break;
            }


            while (!ping.Done())
            {
                if (sw.ElapsedMilliseconds >= MaxMilliseconsPerPing)
                {
                    overtime = true;
                    break;
                }
                yield return(0); // keep this loop tight, to avoid adding local lag to rtt.
            }
            int rtt = (int)sw.ElapsedMilliseconds;


            if (IgnoreInitialAttempt && i == 0)
            {
                // do nothing.
            }
            else if (ping.Successful && !overtime)
            {
                rttSum += rtt;
                replyCount++;
                region.Ping = (int)((rttSum) / replyCount);
                //Debug.Log("region " + region.Code + " RTT " + region.Ping + " success: " + ping.Successful + " over: " + overtime);
            }

            yield return(new WaitForSeconds(0.1f));
        }
        ping.Dispose();

        this.PingsRunning--;

        //Debug.Log("this.PingsRunning: " + this.PingsRunning + " this debug: " + ping.DebugString);
        yield return(null);
    }
コード例 #15
0
ファイル: ToLuaMenu.cs プロジェクト: takaaptech/UnityLua
    public static int UpdateMonoCecil(ref bool EnableSymbols)
    {
        string appFileName = Environment.GetCommandLineArgs()[0];
        string appPath     = Path.GetDirectoryName(appFileName);
        string directory   = appPath + "/Data/Managed/";

        if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.OSXEditor)
        {
            directory = appPath.Substring(0, appPath.IndexOf("MacOS")) + "Managed/";
        }
        string suitedMonoCecilPath = directory +
#if UNITY_2017_1_OR_NEWER
                                     "Unity.Cecil.dll";
#else
                                     "Mono.Cecil.dll";
#endif
        string suitedMonoCecilMdbPath = directory +
#if UNITY_2017_1_OR_NEWER
                                        "Unity.Cecil.Mdb.dll";
#else
                                        "Mono.Cecil.Mdb.dll";
#endif
        string suitedMonoCecilPdbPath = directory +
#if UNITY_2017_1_OR_NEWER
                                        "Unity.Cecil.Pdb.dll";
#else
                                        "Mono.Cecil.Pdb.dll";
#endif
        string suitedMonoCecilToolPath = directory + "Unity.CecilTools.dll";

        if (!File.Exists(suitedMonoCecilPath)
#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER
            && !File.Exists(suitedMonoCecilMdbPath) &&
            !File.Exists(suitedMonoCecilPdbPath)
#endif
            )
        {
            EnableSymbols = false;
            Debug.Log("Haven't found Mono.Cecil.dll!Symbols Will Be Disabled");
            return(-1);
        }

        bool   bInjectionToolUpdated  = false;
        string injectionToolPath      = CustomSettings.injectionFilesPath + "Editor/";
        string existMonoCecilPath     = injectionToolPath + Path.GetFileName(suitedMonoCecilPath);
        string existMonoCecilPdbPath  = injectionToolPath + Path.GetFileName(suitedMonoCecilPdbPath);
        string existMonoCecilMdbPath  = injectionToolPath + Path.GetFileName(suitedMonoCecilMdbPath);
        string existMonoCecilToolPath = injectionToolPath + Path.GetFileName(suitedMonoCecilToolPath);

        try
        {
            bInjectionToolUpdated = TryUpdate(suitedMonoCecilPath, existMonoCecilPath) ? true : bInjectionToolUpdated;
#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER
            bInjectionToolUpdated = TryUpdate(suitedMonoCecilPdbPath, existMonoCecilPdbPath) ? true : bInjectionToolUpdated;
            bInjectionToolUpdated = TryUpdate(suitedMonoCecilMdbPath, existMonoCecilMdbPath) ? true : bInjectionToolUpdated;
#endif
            TryUpdate(suitedMonoCecilToolPath, existMonoCecilToolPath);
        }
        catch (Exception e)
        {
            Debug.LogError(e.ToString());
            return(-1);
        }
        EnableSymbols = true;

        return(bInjectionToolUpdated ? 1 : 0);
    }
コード例 #16
0
ファイル: PlayerController.cs プロジェクト: TCROC/PFAdmin
    public void CreateBuildWithCustomContainer(BuildBundleID identity)
    {
        ShowLoader();
        try {
            PortID[]   configuredPorts   = portButton.transform.parent.GetComponentsInChildren <PortID>(false);
            RegionID[] configuredRegions = regionButton.transform.parent.GetComponentsInChildren <RegionID>(false);

            if (configuredPorts.Length == 0)
            {
                Inform("Error: Ports cannot be empty! Please add a port.");
                return;
            }

            if (configuredRegions.Length == 0)
            {
                Inform("Error: Regions cannot be empty! Please add a region.");
                return;
            }

            List <Port> portList = new List <Port>();
            List <BuildRegionParams> regionList = new List <BuildRegionParams>();

            foreach (var port in configuredPorts)
            {
                portList.Add(port.portIDParams);
            }

            foreach (var region in configuredRegions)
            {
                regionList.Add(region.regionIDParams);
            }

            PlayFabMultiplayerAPI.CreateBuildWithCustomContainer(new CreateBuildWithCustomContainerRequest {
                BuildName               = identity.buildName.text,
                ContainerFlavor         = GetEnumValue <ContainerFlavor>(identity.containerFlavor.options[identity.containerFlavor.value].text),
                ContainerImageReference = new ContainerImageReference {
                    ImageName = identity.containerName.text,
                    Tag       = identity.containerTag.text
                },
                ContainerRunCommand         = "echo \"Server is being allocated...\" >> /data/GameLogs/Server.log",
                MultiplayerServerCountPerVm = int.Parse(identity.serverCountPerVm.text),
                VmSize = GetEnumValue <AzureVmSize>(identity.vmSize.options[identity.vmSize.value].text),


                Ports = portList,
                RegionConfigurations = regionList
            },
                                                                 result => {
                Debug.Log("CREATE BUILD OK: " + result.ToJson());
                buildID.gameObject.SetActive(false);
                InformURL("Build Created Successfully!\n\nBuild ID:\n" + result.BuildId,
                          string.Format("https://developer.playfab.com/en-US/{0}/multiplayer/server/builds", PlayFabSettings.TitleId));
            },
                                                                 error => {
                Debug.LogError("CREATE BUILD FAILURE: " + error.ToString());
                Inform("Build Creation Failure!\n\n" + error.ErrorMessage);
            });
        } catch (System.Exception e) {
            Inform(e.Message);
        }
    }
コード例 #17
0
        public static void LaunchLocalDeployment()
        {
            BuildConfig();

            var command     = Common.SpatialBinary;
            var commandArgs = "local launch";

            var runtimeIp = GdkToolsConfiguration.GetOrCreateInstance().RuntimeIp;

            if (!string.IsNullOrEmpty(runtimeIp))
            {
                commandArgs = $"{commandArgs} --runtime_ip={runtimeIp}";
            }

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                command     = "osascript";
                commandArgs = $@"-e 'tell application ""Terminal""
                                     activate
                                     do script ""cd {SpatialProjectRootDir} && {Common.SpatialBinary} {commandArgs}""
                                     end tell'";
            }

            var processInfo = new ProcessStartInfo(command, commandArgs)
            {
                CreateNoWindow   = false,
                UseShellExecute  = true,
                WorkingDirectory = SpatialProjectRootDir
            };

            var process = Process.Start(processInfo);

            if (process == null)
            {
                Debug.LogError("Failed to start SpatialOS locally.");
                return;
            }

            process.EnableRaisingEvents = true;
            process.Exited += (sender, args) =>
            {
                // N.B. This callback is run on a different thread.
                if (process.ExitCode == 0)
                {
                    return;
                }

                var logPath       = Path.Combine(SpatialProjectRootDir, "logs");
                var latestLogFile = Directory.GetFiles(logPath, "spatial_*.log")
                                    .Select(f => new FileInfo(f))
                                    .OrderBy(f => f.LastWriteTimeUtc).LastOrDefault();

                if (latestLogFile == null)
                {
                    Debug.LogError($"Could not find a spatial log file in {logPath}.");
                    return;
                }

                var message = $"For more information, check the spatial local launch logfile: {latestLogFile.FullName}";

                if (WasProcessKilled(process))
                {
                    Debug.Log(message);
                }
                else
                {
                    Debug.LogError($"Errors occured - {message}");
                }

                process.Dispose();
                process = null;
            };
        }
コード例 #18
0
    public static void CreateMesh_ClassicApi()
    {
        var sw = Stopwatch.StartNew();

        smp1.Begin();
        var meshFilters = FindObjectsOfType <MeshFilter>();

        smp1.End();

        smp2.Begin();
        List <Vector3> allVerts = new List <Vector3>();
        //List<Vector3> allNormals = new List<Vector3>(); // faster to do RecalculateNormals than doing it manually
        List <int> allIndices = new List <int>();

        foreach (var mf in meshFilters)
        {
            var go = mf.gameObject;
            if (go.CompareTag("EditorOnly"))
            {
                DestroyImmediate(go);
                continue;
            }

            var tr    = go.transform;
            var mesh  = mf.sharedMesh;
            var verts = mesh.vertices;
            //var normals = mesh.normals;
            var tris = mesh.triangles;
            for (var i = 0; i < verts.Length; ++i)
            {
                var pos = verts[i];
                pos      = tr.TransformPoint(pos);
                verts[i] = pos;
                //var nor = normals[i];
                //nor = tr.TransformDirection(nor).normalized;
                //normals[i] = nor;
            }
            var baseIdx = allVerts.Count;
            for (var i = 0; i < tris.Length; ++i)
            {
                tris[i] = tris[i] + baseIdx;
            }
            allVerts.AddRange(verts);
            //allNormals.AddRange(normals);
            allIndices.AddRange(tris);
        }
        smp2.End();

        smp3.Begin();
        var newMesh = new Mesh();

        newMesh.name        = "CombinedMesh";
        newMesh.indexFormat = IndexFormat.UInt32;
        newMesh.SetVertices(allVerts);
        //newMesh.SetNormals(allNormals);
        newMesh.SetTriangles(allIndices, 0);
        smp3.End();

        var newGo = new GameObject("CombinedMesh", typeof(MeshFilter), typeof(MeshRenderer));

        newGo.tag = "EditorOnly";
        var newMf = newGo.GetComponent <MeshFilter>();
        var newMr = newGo.GetComponent <MeshRenderer>();

        newMr.material   = AssetDatabase.LoadAssetAtPath <Material>("Assets/CreateMeshFromAllSceneMeshes/MaterialForNewlyCreatedMesh.mat");
        newMf.sharedMesh = newMesh;
        newMesh.RecalculateNormals();

        var dur = sw.ElapsedMilliseconds;

        Debug.Log($"Took {dur/1000.0:F2}sec for {meshFilters.Length} objects, total {allVerts.Count} verts");

        Selection.activeObject = newGo;
    }
コード例 #19
0
 private static void LaunchMenu()
 {
     Debug.Log("Launching SpatialOS locally...");
     EditorApplication.delayCall += LaunchLocalDeployment;
 }
コード例 #20
0
    public static void CreateMesh_MeshDataApi()
    {
        var sw = Stopwatch.StartNew();

        // Find all MeshFilter objects in the scene
        smp1.Begin();
        var meshFilters = FindObjectsOfType <MeshFilter>();

        smp1.End();

        // Need to figure out how large the output mesh needs to be (in terms of vertex/index count),
        // as well as get transforms and vertex/index location offsets for each mesh.
        smp2.Begin();
        var jobs = new ProcessMeshDataJob();

        jobs.CreateInputArrays(meshFilters.Length);
        var inputMeshes = new List <Mesh>(meshFilters.Length);

        var vertexStart = 0;
        var indexStart  = 0;
        var meshCount   = 0;

        for (var i = 0; i < meshFilters.Length; ++i)
        {
            var mf = meshFilters[i];
            var go = mf.gameObject;
            if (go.CompareTag("EditorOnly"))
            {
                DestroyImmediate(go);
                continue;
            }

            var mesh = mf.sharedMesh;
            inputMeshes.Add(mesh);
            jobs.vertexStart[meshCount] = vertexStart;
            jobs.indexStart[meshCount]  = indexStart;
            jobs.xform[meshCount]       = go.transform.localToWorldMatrix;
            vertexStart           += mesh.vertexCount;
            indexStart            += (int)mesh.GetIndexCount(0);
            jobs.bounds[meshCount] = new float3x2(new float3(Mathf.Infinity), new float3(Mathf.NegativeInfinity));
            ++meshCount;
        }
        smp2.End();

        // Acquire read-only data for input meshes
        jobs.meshData = Mesh.AcquireReadOnlyMeshData(inputMeshes);

        // Create and initialize writable data for the output mesh
        var outputMeshData = Mesh.AllocateWritableMeshData(1);

        jobs.outputMesh = outputMeshData[0];
        jobs.outputMesh.SetIndexBufferParams(indexStart, IndexFormat.UInt32);
        jobs.outputMesh.SetVertexBufferParams(vertexStart,
                                              new VertexAttributeDescriptor(VertexAttribute.Position),
                                              new VertexAttributeDescriptor(VertexAttribute.Normal, stream: 1));

        // Launch mesh processing jobs
        var handle = jobs.Schedule(meshCount, 4);

        // Create destination Mesh object
        smp3.Begin();
        var newMesh = new Mesh();

        newMesh.name = "CombinedMesh";
        var sm = new SubMeshDescriptor(0, indexStart, MeshTopology.Triangles);

        sm.firstVertex = 0;
        sm.vertexCount = vertexStart;

        // Wait for jobs to finish, since we'll have to access the produced mesh/bounds data at this point
        handle.Complete();

        // Final bounding box of the whole mesh is union of the bounds of individual transformed meshes
        var bounds = new float3x2(new float3(Mathf.Infinity), new float3(Mathf.NegativeInfinity));

        for (var i = 0; i < meshCount; ++i)
        {
            var b = jobs.bounds[i];
            bounds.c0 = math.min(bounds.c0, b.c0);
            bounds.c1 = math.max(bounds.c1, b.c1);
        }
        sm.bounds = new Bounds((bounds.c0 + bounds.c1) * 0.5f, bounds.c1 - bounds.c0);
        jobs.outputMesh.subMeshCount = 1;
        jobs.outputMesh.SetSubMesh(0, sm, MeshUpdateFlags.DontRecalculateBounds | MeshUpdateFlags.DontValidateIndices | MeshUpdateFlags.DontNotifyMeshUsers);
        Mesh.ApplyAndDisposeWritableMeshData(outputMeshData, new[] { newMesh }, MeshUpdateFlags.DontRecalculateBounds | MeshUpdateFlags.DontValidateIndices | MeshUpdateFlags.DontNotifyMeshUsers);
        newMesh.bounds = sm.bounds;
        smp3.End();

        // Dispose of the read-only mesh data and temporary bounds array
        smp4.Begin();
        jobs.meshData.Dispose();
        jobs.bounds.Dispose();
        smp4.End();

        // Create new GameObject with the new mesh
        var newGo = new GameObject("CombinedMesh", typeof(MeshFilter), typeof(MeshRenderer));

        newGo.tag = "EditorOnly";
        var newMf = newGo.GetComponent <MeshFilter>();
        var newMr = newGo.GetComponent <MeshRenderer>();

        newMr.material   = AssetDatabase.LoadAssetAtPath <Material>("Assets/CreateMeshFromAllSceneMeshes/MaterialForNewlyCreatedMesh.mat");
        newMf.sharedMesh = newMesh;
        //newMesh.RecalculateNormals(); // faster to do normal xform in the job

        var dur = sw.ElapsedMilliseconds;

        Debug.Log($"Took {dur/1000.0:F2}sec for {meshCount} objects, total {vertexStart} verts");

        Selection.activeObject = newGo;
    }
コード例 #21
0
        public static void LaunchClient()
        {
            var command            = Common.SpatialBinary;
            var commandArgs        = "local worker launch UnityClient default";
            var unityClientZipName = "*****@*****.**";

            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                command            = "osascript";
                commandArgs        = $@"-e 'tell application ""Terminal""
                                     activate
                                     do script ""cd {SpatialProjectRootDir} && {Common.SpatialBinary} {commandArgs}""
                                     end tell'";
                unityClientZipName = "*****@*****.**";
            }

            var processInfo = new ProcessStartInfo(command, commandArgs)
            {
                CreateNoWindow   = false,
                UseShellExecute  = true,
                WorkingDirectory = SpatialProjectRootDir
            };

            var process = Process.Start(processInfo);

            if (process == null)
            {
                Debug.LogError("Failed to start a standalone client locally.");
                return;
            }

            process.EnableRaisingEvents = true;
            process.Exited += (sender, args) =>
            {
                // N.B. This callback is run on a different thread.
                if (process.ExitCode == 0)
                {
                    return;
                }

                var latestLogFile     = GetClientLogFileFullPath();
                var latestClientBuild = Path.GetFullPath(Path.Combine(BuildPath, unityClientZipName));

                if (!File.Exists(latestClientBuild))
                {
                    Debug.LogError($"Local client build missing. Couldn't find the Unity Client at {latestClientBuild}.");
                    return;
                }

                if (!File.Exists(latestLogFile))
                {
                    Debug.LogError($"Could not find a standalone client log file {latestLogFile}.");
                    return;
                }

                var message = $"For more information, check the Unity Standalone Client local launch logfile: {latestLogFile}";

                if (WasProcessKilled(process))
                {
                    Debug.Log(message);
                }
                else
                {
                    Debug.LogError($"Errors occured - {message}");
                }

                process.Dispose();
                process = null;
            };
        }
コード例 #22
0
 // if game objects have been hit by raycast, react to it
 void Update()
 {
     foreach (var t in Input.touches)
     {
         if (t.phase != TouchPhase.Began)
         {
             continue;
         }
         var        ray = Camera.main.ScreenPointToRay(t.position);
         RaycastHit hitInfo;
         if (Physics.Raycast(ray, out hitInfo))
         {
             Debug.Log(PositionSaveSystem.rotation + " -- " + PositionSaveSystem.position);
             Debug.Log(hitInfo.transform.gameObject.name + " clicked");
             // if star has been clicked, update the status of this star to collected
             if (hitInfo.transform.gameObject.name == "airplane-star" ||
                 hitInfo.transform.gameObject.name == "old-images-star" ||
                 hitInfo.transform.gameObject.name == "muse-star" ||
                 hitInfo.transform.gameObject.name == "history-star" ||
                 hitInfo.transform.gameObject.name == "products-star")
             {
                 StarCollected(hitInfo.transform.gameObject.name);
             }
             // if an answer of a question pannel has been clicked, show a star or fail pannel based on answer
             else if (hitInfo.transform.gameObject.name.Contains("Answer"))
             {
                 var        hit      = hitInfo.transform.gameObject;
                 GameObject pannel   = hit.transform.parent.gameObject;
                 GameObject question = pannel.transform.parent.gameObject;
                 if (hit.name == "Answer - Pralinen")
                 {
                     pannel.gameObject.SetActive(false);
                     question.transform.Find("products-star").gameObject.SetActive(true);
                 }
                 else if (hit.name == "Answer - Brot")
                 {
                     GameObject wrongAnswer = question.transform.Find("Pannel - Wrong").gameObject;
                     StartCoroutine(AnswerWrong(pannel, wrongAnswer));
                 }
                 else if (hit.name == "Answer - 1904")
                 {
                     pannel.gameObject.SetActive(false);
                     question.transform.Find("history-star").gameObject.SetActive(true);
                 }
                 else if (hit.name == "Answer - 2001")
                 {
                     GameObject wrongAnswer = question.transform.Find("Pannel - Wrong").gameObject;
                     StartCoroutine(AnswerWrong(pannel, wrongAnswer));
                 }
             }
             else
             // show mini game button
             {
                 gameStartScreen.SetActive(true);
                 selectedMiniGame     = Array.Find(GameProgress.miniGames, minigame => minigame.getTitleKey() == hitInfo.transform.gameObject.name);
                 gameTitle.text       = selectedMiniGame.getTitle();
                 gameDescription.text = selectedMiniGame.getDescription();
                 FindObjectOfType <AudioManager>().Play(selectedMiniGame.getTitleKey());
                 gamePlayButton.GetComponent <Button>().onClick.AddListener(LoadScene);
                 // if the mini game is find-alex, show emma insted of alex
                 if (selectedMiniGame.getTitleKey() == "find-alex")
                 {
                     imageAlex.gameObject.GetComponent <Image>().sprite = emma;
                 }
                 else
                 {
                     imageAlex.gameObject.GetComponent <Image>().sprite = alex;
                 }
             }
         }
     }
 }
コード例 #23
0
 public void TestRenamedAction()
 {
     Debug.Log("[SRDebug] TestRenamedAction() invoked");
 }
コード例 #24
0
ファイル: NetCore.cs プロジェクト: jok886/6020FD772C01DD09
    public static void ReConnect()
    {
        lock (GameManager.LockObj) {
            if (_bReconnecting)
            {
                return;
            }

            _bReconnecting = true;
        }
        Debug.Log("Connect Timeout, reConnectCount is " + _reConnectCount);
        //Debug.Log("Close socket handle " + socket.Handle);
        recvQueue.Clear();

        recvStream.Reset();

        //lin: reset this static pos
        receivePosition = 0;
        wantDataSize    = 0;

        if (PreConnected)
        {
            if (socket.Connected)
            {
                try{
                    socket.Shutdown(SocketShutdown.Both);
                }catch (Exception ee) {
                    Debug.Log("shut down error code " + ((SocketException)ee).ErrorCode);
                    Debug.Log("shutdown failed beacuse of " + ee.ToString());
                }
                Debug.Log("shutdown ended in reconnect");
            }

            try {
                Debug.Log("start close socket in reconnect");
                socket.Close();
                Debug.Log("socket close in reconnect");
            } catch (Exception ex) {
                Debug.Log(((SocketException)ex).ErrorCode);
                Debug.Log("Close socket failed beacuse of socket error:  " + ex.ToString());
            }
#if UNITY_IOS && !UNITY_EDITOR
            socket             = null;
            socket             = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.NoDelay     = true;
            socket.LingerState = new LingerOption(true, 0);
            Debug.Log("create new socket " + socket.Handle);
#else
            //on PC, new socket will get the same socket, so we need to new another one first, then close the current socket
            if (socket == bakedSocket)
            {
                bakedSocket             = new Socket(_addressFamily, SocketType.Stream, ProtocolType.Tcp);
                bakedSocket.NoDelay     = true;
                bakedSocket.LingerState = new LingerOption(true, 0);
                Debug.Log("create new baked socket " + bakedSocket.Handle);
            }

            socket = null;

            socket = bakedSocket;
            Debug.Log("change socket now");
#endif
            PreConnected = false;
            //bakedSocket = null;
        }


        //if (_reConnectCount > 0)
        SocketDisconnectHandler(null, EventArgs.Empty);
    }
コード例 #25
0
 public void TestLogInfo()
 {
     Debug.Log("Test Info");
 }
コード例 #26
0
ファイル: NetCore.cs プロジェクト: jok886/6020FD772C01DD09
    public static void Receive(IAsyncResult ar = null)
    {
        if (!bConnected)
        {
            return;
        }

        if (ar != null)
        {
            try {
                receivePosition += socket.EndReceive(ar);
            }
            catch (Exception e) {
                Debug.Log("Lost network " + ((SocketException)e).ErrorCode);
                Debug.Log("Lost network " + ((SocketException)e).ToString());
                return;                //only PC can catch this exception when network closed, use heartbeat to detect lost connection

                //出现10053的原因是因为在你执行这次send的时候对端已经执行过closesocket了,而发送的数据还是被成功的推入了发送缓冲区中,因此返回了0,
                //此时你可能还没得到FIN消息,而紧接着recv这边就得到了对端关闭socket的FIN消息,因此此时需要放弃发送缓冲中的数据,异常终止连接,
                //所以得到了10053错误:您的主机中的软件中止了一个已建立的连接。

                //而为什么又能得到10054的错误号,原因应该在于你设置了SO_LINGER了,一但设置了它,则有一个等待奔洌?
                //在该等待时间内可以处理发送缓冲区的数据,一但超时或者发送缓冲都被发送完并被确认,则服务端有可能发送RST消息而不是FIN,
                //此时就应该得到重置错误,也就是10054。

                recvQueue.Clear();

                recvStream.Reset();

                //lin: reset this static pos
                receivePosition = 0;

                if (((SocketException)e).ErrorCode == 10054)//WSAECONNRESET   断线 10054: An existing connection was forcibly closed by the remote host.
                {
                    SocketDisconnectHandler(null, EventArgs.Empty);
                }
                else if (((SocketException)e).ErrorCode == 10053) // 10053: An established connection was aborted by the software in your host machine.
                {
                    SocketDisconnectHandler(null, EventArgs.Empty);
                }

                Debug.LogWarning(e.ToString());
            }
        }

        int i = recvStream.Position;

        while (receivePosition >= i + 2)
        {
            int length = 0;
            int curLen = (receivePosition - i);
            if (wantDataSize == 0)
            {
                length = (recvStream[i] << 8) | recvStream[i + 1];
                //Debug.Log("received data : " + length);
                Debug.Assert(length > 0, "received data size <= 0");
                int sz = length + 2;

                recvStream.Seek(2, SeekOrigin.Current);
                curLen      -= 2;
                receivedData = new byte[length];

                if (curLen >= length)
                {
                    recvStream.Read(receivedData, 0, length);
                    recvQueue.Enqueue(receivedData);
                    i += sz;
                }
                else
                {
                    wantDataSize = length - curLen;//待接收字符
                    // Debug.Log("want received data 1: " + wantDataSize);
                    recvStream.Read(receivedData, 0, curLen);
                    i += (curLen + 2);
                }
            }
            else
            {
                if (curLen >= wantDataSize)
                {
                    recvStream.Read(receivedData, receivedData.Length - wantDataSize, wantDataSize);
                    recvQueue.Enqueue(receivedData);
                    i += wantDataSize;
                    //Debug.Log("received data 2: " + wantDataSize + curLen);
                    wantDataSize = 0;
                }
                else
                {
                    recvStream.Read(receivedData, receivedData.Length - wantDataSize, curLen);
                    i            += curLen;
                    wantDataSize -= curLen;
                    //Debug.Log("want received data 2: " + wantDataSize);
                }
            }
        }

        if (receivePosition == recvStream.Buffer.Length)
        {
            recvStream.Seek(0, SeekOrigin.End);
            recvStream.MoveUp(i, i);
            receivePosition = recvStream.Position;
            recvStream.Seek(0, SeekOrigin.Begin);
        }

        try {
            socket.BeginReceive(recvStream.Buffer, receivePosition,
                                recvStream.Buffer.Length - receivePosition,
                                SocketFlags.None, receiveCallback, socket);
        }
        catch (Exception e) {
            Debug.LogWarning(e.ToString());
        }
    }
コード例 #27
0
    private void QueryForVoiceListLs(EasyVoiceSettings settings)
    {
        Process voiceListRequest = new Process();


        //ProcessStartInfo startInfo = new ProcessStartInfo();

        ////startInfo.FileName = Application.dataPath + @"/../EasyVoiceApps/EasyVoiceMacTerminalSpoof/bin/Debug/EasyVoiceMacTerminalSpoof.exe";
        ////startInfo.Arguments = "-ls";
        //startInfo.FileName = @"ls";
        //startInfo.Arguments = "/System/Library/Speech/Voices";
        //startInfo.CreateNoWindow = true;
        //startInfo.RedirectStandardOutput = true; // we need to capture it
        //startInfo.RedirectStandardError = true; // we need to capture it
        //startInfo.UseShellExecute = false; // must be false for redirect output

        //voiceListRequest.StartInfo = startInfo;


        //voiceListRequest.StartInfo.FileName = Application.dataPath + @"/../EasyVoiceApps/EasyVoiceMacTerminalSpoof/bin/Debug/EasyVoiceMacTerminalSpoof.exe";
        //voiceListRequest.StartInfo.Arguments = "-ls";
        voiceListRequest.StartInfo.FileName               = @"ls";
        voiceListRequest.StartInfo.Arguments              = "/System/Library/Speech/Voices";
        voiceListRequest.StartInfo.CreateNoWindow         = true;
        voiceListRequest.StartInfo.RedirectStandardOutput = true;  // we need to capture it
        voiceListRequest.StartInfo.RedirectStandardError  = true;  // we need to capture it
        voiceListRequest.StartInfo.UseShellExecute        = false; // must be false for redirect output

#if DEBUG_MESSAGES
        Debug.Log("Starting query...");
#endif
        try
        {
            voiceListRequest.Start();

            voiceListRequest.WaitForExit();
        }
        catch (Exception exception)
        {
#if USE_CLOSE
            voiceListRequest.Close();
#endif
            Debug.LogError("Process start/run error: " + exception);
            return;
        }

        if (voiceListRequest.ExitCode == 0)
        {
            using (StreamReader streamReader = voiceListRequest.StandardOutput)
            {
                settings.voiceNames        = new List <string>();
                settings.voiceDescriptions = new List <string>();
                settings.voiceGenders      = new List <string>();
                settings.voiceAges         = new List <string>();

                while (!streamReader.EndOfStream)
                {
                    string reply = streamReader.ReadLine();

                    MatchCollection matches = Regex.Matches(reply, @"([^\s]+?)\.SpeechVoice");

                    foreach (Match match in matches)
                    {
                        settings.voiceNames.Add(match.Groups[1].ToString());
                        settings.voiceDescriptions.Add("");
                        settings.voiceGenders.Add("");
                        settings.voiceAges.Add("");
#if DEBUG_MESSAGES
                        Debug.Log(settings.voiceNames[settings.voiceNames.Count - 1] + " -- " +
                                  settings.voiceDescriptions[settings.voiceNames.Count - 1]);
#endif
                    }
                }

                if (settings.voiceNames.Count == 0)
                {
                    Debug.LogError("Process couldn't parse any speech names");
                    return;
                }
                //string result = streamReader.ReadToEnd();
                //Debug.Log(result);
            }
        }
        else
        {
            using (StreamReader streamReader = voiceListRequest.StandardError)
            {
                string result = streamReader.ReadToEnd();
                Debug.LogError("Process error: " + result);
            }
        }

#if USE_CLOSE
        voiceListRequest.Close();
#endif
    }
コード例 #28
0
ファイル: NetCore.cs プロジェクト: jok886/6020FD772C01DD09
    public static void Dispatch()
    {
        //Debug.Log("dis");
        try
        {
            package pkg = new package();

            if (recvQueue.Count > 20)
            {
                Debug.Log("recvQueue.Count: " + recvQueue.Count);
            }

            while (recvQueue.Count > 0)
            {
                //Debug.Log("dis");
                byte[] data   = recvPack.unpack(recvQueue.Dequeue());
                int    offset = pkg.init(data);

                int  tag     = (int)pkg.type;
                long session = (long)pkg.session;

                if (pkg.HasType)
                {
                    //Debug.Log("type");
                    try
                    {
                        RpcReqHandler rpcReqHandler = NetReceiver.GetHandler(tag);
                        if (rpcReqHandler != null)
                        {
                            SprotoTypeBase rpcRsp = rpcReqHandler(protocol.GenRequest(tag, data, offset));
                            if (pkg.HasSession)
                            {
                                Send(rpcRsp, session, tag);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Log("NetReceiver exception: " + e.Message + tag + session + offset);
                        throw;
                    }
                }
                else
                {
                    //Debug.Log("no type");
                    try
                    {
                        RpcRspHandler rpcRspHandler = NetSender.GetHandler(session);
                        if (rpcRspHandler != null)
                        {
                            ProtocolFunctionDictionary.typeFunc GenResponse;
                            sessionDict.TryGetValue(session, out GenResponse);
                            rpcRspHandler(GenResponse(data, offset));
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Log("NetReceiver exception: " + e.Message + tag + session + offset);
                        throw;
                    }
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("Dispatch exception: " + e.Message);
            throw;
        }
    }
コード例 #29
0
    public override void QueryForVoiceList(EasyVoiceSettings settings)
    {
        settings.voiceNames        = null;
        settings.voiceDescriptions = null;
        settings.voiceGenders      = null;
        settings.voiceAges         = null;

        Process voiceListRequest = new Process();


        //ProcessStartInfo startInfo = new ProcessStartInfo();

        ////startInfo.FileName = Application.dataPath + @"/../EasyVoiceApps/EasyVoiceMacTerminalSpoof/bin/Debug/EasyVoiceMacTerminalSpoof.exe";
        ////startInfo.Arguments = "-v '?' -break";
        //startInfo.FileName = @"/usr/bin/say";
        //startInfo.Arguments = "-v '?'";
        //startInfo.CreateNoWindow = true;
        //startInfo.RedirectStandardOutput = true; // we need to capture it
        //startInfo.RedirectStandardError = true; // we need to capture it
        //startInfo.UseShellExecute = false; // must be false for redirect output

        //voiceListRequest.StartInfo = startInfo;


        //voiceListRequest.StartInfo.FileName = Application.dataPath + @"/../EasyVoiceApps/EasyVoiceMacTerminalSpoof/bin/Debug/EasyVoiceMacTerminalSpoof.exe";
        //voiceListRequest.StartInfo.Arguments = "-v '?' -break";
        voiceListRequest.StartInfo.FileName               = @"/usr/bin/say";
        voiceListRequest.StartInfo.Arguments              = "-v '?'";
        voiceListRequest.StartInfo.CreateNoWindow         = true;
        voiceListRequest.StartInfo.RedirectStandardOutput = true;  // we need to capture it
        voiceListRequest.StartInfo.RedirectStandardError  = true;  // we need to capture it
        voiceListRequest.StartInfo.UseShellExecute        = false; // must be false for redirect output


#if DEBUG_MESSAGES
        Debug.Log("Starting query...");
#endif
        try
        {
            voiceListRequest.Start();

            voiceListRequest.WaitForExit();
        }
        catch (Exception exception)
        {
#if USE_CLOSE
            voiceListRequest.Close();
#endif
            Debug.LogError("Process start/run error: " + exception);
            return;
        }

        if (voiceListRequest.ExitCode == 0)
        {
            using (StreamReader streamReader = voiceListRequest.StandardOutput)
            {
                settings.voiceNames        = new List <string>();
                settings.voiceDescriptions = new List <string>();
                settings.voiceGenders      = new List <string>();
                settings.voiceAges         = new List <string>();

                while (!streamReader.EndOfStream)
                {
                    string reply = streamReader.ReadLine();

                    // Skip empty strings
                    if (string.IsNullOrEmpty(reply))
                    {
                        continue;
                    }

                    Match match = Regex.Match(reply, @"^([^#]+?)\s*([^ ]+)\s*# (.*?)$");

                    if (match.Success)
                    {
                        settings.voiceNames.Add(match.Groups[1].ToString());
                        settings.voiceDescriptions.Add(match.Groups[3].ToString());
                        settings.voiceGenders.Add("");
                        settings.voiceAges.Add("");
#if DEBUG_MESSAGES
                        Debug.Log(settings.voiceNames[settings.voiceNames.Count - 1] + " -- " +
                                  settings.voiceDescriptions[settings.voiceNames.Count - 1]);
#endif
                    }
                    else
                    {
#if DEBUG_MESSAGES // Apparently custom voices can insert extra lines into the terminal output, so we cannot print this in production
                        Debug.LogError("Process returned unexpected line: " + reply);
#endif
                    }
                }
                //string result = streamReader.ReadToEnd();
                //Debug.Log(result);
            }
        }
        else
        {
            using (StreamReader streamReader = voiceListRequest.StandardError)
            {
                string result = streamReader.ReadToEnd();

                // If "say" reports there is no '?' voice, then it doesn't support -v '?' syntax and we need to do the ls speech folder
                if (result.StartsWith("Voice `?' not found"))
                {
#if USE_CLOSE
                    voiceListRequest.Close();
#endif
                    QueryForVoiceListLs(settings);
                    return;
                }

                Debug.LogError("Process error: " + result);
            }
        }

#if USE_CLOSE
        voiceListRequest.Close();
#endif
    }
コード例 #30
0
ファイル: UDLRManager.cs プロジェクト: ayesen/CGJ
    public void LevelFourDetect()
    {
        Vector2 pos = new Vector2(pC.x_pos, pC.y_pos);

        Debug.Log(pos);
        if (pos.Equals(new Vector2(12, 1)))
        {
            intersection = 0;
        }
        if (pos.Equals(new Vector2(12, 3)))
        {
            intersection = 1;
        }
        if (pos.Equals(new Vector2(12, 5)))
        {
            intersection = 2;
        }
        if (pos.Equals(new Vector2(12, 7)))
        {
            intersection = 3;
        }
        if (pos.Equals(new Vector2(12, 9)))
        {
            intersection = 4;
        }
        if (pos.Equals(new Vector2(12, 11)))
        {
            intersection = 5;
        }
        if (pos.Equals(new Vector2(12, 13)))
        {
            intersection = 6;
        }
        if (pos.Equals(new Vector2(12, 15)))
        {
            intersection = 7;
        }
        if (pos.Equals(new Vector2(12, 17)))
        {
            intersection = 8;
        }
        if (pos.Equals(new Vector2(12, 19)))
        {
            intersection = 9;
        }
        if (pos.Equals(new Vector2(12, 21)))
        {
            intersection = 10;
        }
        if (pos.Equals(new Vector2(12, 23)))
        {
            intersection = 11;
        }
        if (pos.Equals(new Vector2(12, 25)))
        {
            intersection = 12;
        }
        if (pos.Equals(new Vector2(12, 27)))
        {
            intersection = 13;
        }
        if (pos.Equals(new Vector2(12, 29)))
        {
            intersection = 14;
        }
        if (pos.Equals(new Vector2(12, 31)))
        {
            intersection = 15;
        }
        if (pos.Equals(new Vector2(12, 33)))
        {
            intersection = 16;
        }
        if (pos.Equals(new Vector2(12, 35)))
        {
            intersection = 17;
        }
        if (pos.Equals(new Vector2(12, 37)))
        {
            intersection = 18;
        }
        if (pos.Equals(new Vector2(12, 39)))
        {
            intersection = 19;
        }
        if (pos.Equals(new Vector2(12, 41)))
        {
            intersection = 20;
        }
        if (pos.Equals(new Vector2(12, 43)))
        {
            intersection = 21;
        }
        if (pos.Equals(new Vector2(12, 45)))
        {
            intersection = 22;
        }
    }