RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

问题[unity3d]

Martin Hope
Friendlyap
Asked: 2025-04-02 15:13:28 +0000 UTC

使用 MVx 模式时,如何在 Unity 中组织文件夹层次结构?

  • 5

我计划为我的投资组合创建一个小项目并在其中使用 MVP 模式。我之前从未使用过任何建筑模式。问题是在 Unity 中如何组织文件夹和脚本的层次结构。是否有必要对 Model、View 和 Presenter 文件夹进行严格的区分?而且脚本名里需要加上后缀Model、View、Presenter吗?提前感谢大家。

unity3d
  • 1 个回答
  • 38 Views
Martin Hope
Даниил Ганин
Asked: 2024-12-08 03:45:45 +0000 UTC

使用 ParrelSync 或多人游戏模式时出现网络问题

  • 5

当我使用ParrelSync或多人游戏模式时,Unity 网络出现问题。
这意味着当我启动 Unity 游戏的两个窗口时, Unity Relay 和 Unity Lobby突然停止正常工作。我没有对 GameObject 的 Netcode 进行测试,因为在我开始使用它之前就会出现问题。事件过程: 两个游戏窗口以 Unity 服务中的授权开始(代码如下),并且此授权可以持续很长时间,通常会失败并重新开始。如果他们成功登录,他们会收到不同的 ID。此外,当我想在其中一个客户端上创建大厅时,创建大厅的数据交换需要很长时间,这可能会导致超时,并且在创建大厅的同时还会创建中继,但由于等待服务器响应时间较长,因此无法创建中继。一切进展顺利: 通过一个游戏窗口,一切正常。 当我尝试使用游戏的组装版本(构建和运行),从而获得两个窗口(一个在 Unity 游戏模式中,一个在构建中)时,一切都运行得很快且正确。另外: 我的代码中没有不断联系 Unity 服务器的循环;调用只发生一次,如下面的代码所示,并且不会向大厅询问有关其更新的数据。 场景开始时授权立即发生,大厅的创建由玩家发起。当两个游戏窗口进入场景并尝试登录时,问题立即出现。授权后(如果可能),问题不会消失。 我想找到一个允许使用多人游戏模式的解决方案











授权码

    private async void Start()
    {
        try
        {
            await UnityServices.InitializeAsync();

            AuthenticationService.Instance.SignedIn += () =>
            {
                Debug.Log("Singed in " + AuthenticationService.Instance.PlayerId);
            };

            await AuthenticationService.Instance.SignInAnonymouslyAsync();

            playerName = "Player(" + Random.Range(0, 10) + ")";
        }
        catch (AuthenticationException ex)
        {
            Debug.LogError(ex);
        }
    }

授权日志

[Authentication]: Network error detected, retrying...
0x00007ffcef4d6bdd (Unity) StackWalker::ShowCallstack
0x00007ffcef4e6b99 (Unity) PlatformStacktrace::GetStacktrace
0x00007ffcf075132e (Unity) Stacktrace::GetStacktrace
0x00007ffcf0cf9cbf (Unity) DebugStringToFile
0x00007ffcee603575 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x0000015777a6db2d (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log_Injected (UnityEngine.LogType,UnityEngine.LogOption,UnityEngine.Bindings.ManagedSpanWrapper&,intptr)
0x0000015777a6d9f3 (Mono JIT Code) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x0000015777a6d62b (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
0x000001583ecdab7d (Mono JIT Code) UnityEngine.Logger:LogWarning (string,object)
0x000001583ecdaa3d (Mono JIT Code) Unity.Services.Authentication.Logger:LogWarning (object) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Utilities/Logger.cs:17)
0x000001583ecda803 (Mono JIT Code) Unity.Services.Authentication.WebRequest:RequestCompleted (System.Threading.Tasks.TaskCompletionSource`1<string>,long,bool,bool,string,string,System.Collections.Generic.IDictionary`2<string, string>) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Network/WebRequest.cs:182)
0x000001583ecd90c3 (Mono JIT Code) Unity.Services.Authentication.WebRequest/<>c__DisplayClass16_0:<SendAttemptAsync>b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Network/WebRequest.cs:83)
0x000001583ecd8f1b (Mono JIT Code) UnityEngine.AsyncOperation:InvokeCompletionEvent ()
0x000001584942ef08 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffcf408699e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffcf3fc8444 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffcf3fc8530 (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ffcef3fabf4 (Unity) scripting_method_invoke
0x00007ffcef3d2983 (Unity) ScriptingInvocation::Invoke
0x00007ffcef3cdc45 (Unity) ScriptingInvocation::Invoke<void>
0x00007ffcef56b509 (Unity) Scripting::UnityEngine::AsyncOperationProxy::InvokeCompletionEvent
0x00007ffcef06c758 (Unity) AsyncOperation::InvokeCoroutine
0x00007ffcefac0f8c (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007ffcefac1181 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007ffceefeabaa (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007ffcef078cbc (Unity) `InitPlayerLoopCallbacks'::`2'::EarlyUpdateExecuteMainThreadJobsRegistrator::Forward
0x00007ffcef047fc7 (Unity) ExecutePlayerLoop
0x00007ffcef048137 (Unity) ExecutePlayerLoop
0x00007ffcef04d26f (Unity) PlayerLoop
0x00007ffcf014f22a (Unity) EditorPlayerLoop::Execute
0x00007ffcf0165be7 (Unity) PlayerLoopController::InternalUpdateScene
0x00007ffcf016799d (Unity) PlayerLoopController::UpdateSceneIfNeededFromMainLoop
0x00007ffcf0161751 (Unity) Application::TickTimer
0x00007ffcf075603a (Unity) MainMessageLoop
0x00007ffcf075bd12 (Unity) UnityMain
0x00007ff78e092fba (Unity) __scrt_common_main_seh
0x00007ffd5de47374 (KERNEL32) BaseThreadInitThunk
0x00007ffd5f09cc91 (ntdll) RtlUserThreadStart

两个正在运行的游戏窗口的屏幕截图: 使用多人游戏模式同时运行两个游戏模拟

unity3d
  • 1 个回答
  • 21 Views
Martin Hope
Алексей
Asked: 2024-12-01 06:32:37 +0000 UTC

获取对象旋转

  • 5

有一个物体 - 比如说一个“子弹”,还有一个角色 - 比如说一个“人”,当子弹与人相撞时,您需要获取人的旋转和子弹的方向,以便知道影响来自哪一侧并根据此数据打开适当的动画吗?

unity3d
  • 1 个回答
  • 25 Views
Martin Hope
Egor
Asked: 2024-11-25 19:56:04 +0000 UTC

二维空间物体的物理计算

  • 8

我完全糊涂了。为什么臭名昭著的太空飞行模拟器中的轨道是稳定的、封闭的、像一个圆圈,而我的轨道却像带有电子的原子核。

也许值得使用其他一些我不知道的物理方法,或者我的计算中有错误,我不确定。下面是我的代码。

我马上说,轨迹的具体显示没有任何错误,物体实际上沿着轨迹清晰地移动。

太空飞行模拟器

我的 Unity 项目

void Gravity()
{
    if (planet == null) return;

    Vector2 dirToPlanet = (planet.transform.position - transform.position).normalized;
    float dist = dirToPlanet.magnitude;

    float gravityForce = gravitationalConstant * (shuttleMass * planetMass) / (dist * dist);

    Vector2 gravity = dirToPlanet * gravityForce;
    shuttleRB.AddForce(gravity * 0.1f);
}
unity3d
  • 3 个回答
  • 87 Views
Martin Hope
Не скажу я вам имя
Asked: 2024-10-07 21:28:06 +0000 UTC

Unity 中的设置窗口

  • 5

在一些用 Unity 制作的游戏中,您可以在启动时看到类似的窗口(例如,Fears To Fathom 或 The Forest):

如何制作相同的窗口?我查遍了互联网,找不到答案,也许我只是谷歌搜索错误,或者也许没有答案。

unity3d
  • 2 个回答
  • 37 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5