Страницы

четверг, 12 мая 2022 г.

How to fix most "LAN server not found" problems in Windows 10

 Hello, guys! Most of the solutions found in internet, even from support (example here) talks about machines must be reachable and be on same subnet (e.g. 192.168.x.x). But I didn't find anyone saying why and how to do that easily (workarounds exists, but don't guarantee 100% working).

So, at first, let's understand why. Computer reachability can be easily checked typing (in cmd, Run -> cmd, enter):

ping <ip here, better ip4, e.g. 192.168.1.106>

But it's not enough for games. I have had a hard time setting up connection in Sacred. Both PC was connected to same router through same wifi. Both can "ping" each other successfully. But Sacred wount work. While other game works. So what may be the problem with Sacred?

Let's investigate. To know the network registration (IP), we can type:

ipconfig

Usually, we will see only one registration here. But nowadays, when we have virtualization, vpns, etc., we will see several. It's because several network connections created to provide virtualized OSes the connectivity or even register our PC in other part of the world. 

The problem is that game selects one of the connections, not scan all of them (especially old ones). The solution is to restrict acces to them or disable them for time playing. Many ways to do that. That's one way to disable:

1. Open network adapters window. E.g. type in cmd:

ncpa.cpl

2. Disable each adapter except the one that gives you connection (right click, select disable). Note: you need to reeanable all disabled adapters after playing. So better write them down before.

3. Check you still reach PC, that will be running as server. E..g. type in cmd:

ping <ip of other PC>

That's all! You can run the game and ensure it will find server host!

Solution tested on:

Sacred (first),

Battlefront 2 (2005 year)


Will note, that there are easier solution which may be not affordable for all. You connect both PCs to some VPN. From now on, they are on same network and by default, game must use this connection. It's how I trobleshooted playing Neverwinter Nights Enhanced Edition. Sadly, it's not working for all, e.g. for Battlefront 2.


Hope this helps someone. Thank you for reading!

вторник, 6 августа 2019 г.

Unity code: assets saving and importing

When you have unsaved changes, you need this method: AssetDatabase.SaveAssets();
When you changed assets externally: AssetDatabase.ImportAsset(asset) or AssetDatabase.Refresh()
Note: both have ImportAssetOptions. Interesting ones:
  - DontDownloadFromCacheServer - helpful to trobleshoot cache server problems,
  - ForceSynchronousImport - in new versions of unity, asset import can be async. So, if your code requires all assets imported, you need to block, so use this option.

четверг, 31 августа 2017 г.

Опасный DontDestroyOnLoad

DontDestroyOnLoad позволяет компоненте пережить загрузку/перезагрузку сцены. По сути они живы пока жив процесс приложения. Порой, их становится все больше компонент (по сути почти все что работает с нативом - хелпер крашлитики, загрузчик obb, нотификации, дзендеск и др.). Подводный камень DontDestroyOnLoad в том, что он действует на сам gameObject. Это может быть неожиданно для скриптов, которые уже висели на этом gameObject :) Чтобы подстраховаться от такой неприятной случайности можно не дергать этот метод а вместо этого писать над классом атрибут RequireComponent(typeof(DontDestroyOnLoad)).

public class DontDestroyOnLoad
{
  private void Awake()
  {
    DontDestroyOnLoad(gameObject);
  }
}

Тогда хотя бы в редакторе видно не залезая в код, каким компонентам нужен DontDestroyOnLoad - он добавится автоматически.

Решил поделиться. Хотя вообще проще сделать отдельный gameObject в старт-сцене, а на нем повесить какой-нибудь DontDestroyOnLoadController и все компоненты, которым нужно такое поведение. В этом компоненте еще можно и порядком инициализации управлять.

PS внимание, все что DontDestroyOnLoad всегда висит в памяти, а значит нужно озаботиться о том, чтобы ссылаться на как можно меньше ресурсов и выгружать их как только они стали ненужны

четверг, 15 июня 2017 г.

When Unity loads obb automagically?

When Unity loads obb automagically? When it resumes from pause. So, UnityObbDownloader plugin works because it starts it's own activity (so unity activity paused) after downloading, unity activity resumes so file is downloaded. Of course, obb loaded automagically at unity app start too.

Which code may be used to force check obb:

(javacode, you need to implement regular android activity in java to do that, you may take com.unity3d.UnityPlayerActivity as example)
unityPlayer.pause();
unityPlayer.resume();

Not working code, which you may find all over internet:

1. WWW www = WWW.LoadFromCacheOrDownload("file://" + obbPath, 0);
yield return www;

2. yeild return new WaitForSeconds(3-5);

So, people asking why it's not working for them actually may be not using UnityObbDownloader so no activity, no pause, resume, you've got the point.

It's a shame for Unity that they don't document it anywhere and didn't do a method to check for obb. Because, regular Unity game uses one activity with one UnityPlayer in it and if you download drawing your UI in game style like we all do now you have 2 options after download finish:
1. quit app. On next launch Unity will check for obb and use it
2. trigger pause-resume somehow (invisible activity or code I tested above). Weird

воскресенье, 21 мая 2017 г.

How Unity notifies about innerException: rethrow in stack

Suppose code:

public void TestCodeBelowRxChainExecutedDueExceptionHandled()
        {
            UiLogger.Trace("1");
            Observable.Return(1)
                .Select(a =>
                {
                    throw new InvalidOperationException("aa");
                    return a;
                })
                .Subscribe(
                    Actions.Empty,
                    exception => Debug.LogException(new AssertionFailedException(exception, "mmm assertion failed")); // (*)
            UiLogger.Trace("2"); // not reached if not (*)
        }

четверг, 11 мая 2017 г.

Rx in Unity with favor to synchronous code

Let's look at what rx is. Someone says it's about thinking of asynchronous operations as data flows and of rx operators as flow combining operations - join, merge, concat, transform (select/selectMany), etc. I prefer thinking that way. And yes, rx is somewhat about functional programming, it can be combined with LINQ.