UNSAFECSHARP Telegram 271
Player Loop

Вместо MonoBehaviour на сцене можно использовать инжект в текущий луп. Для этого нужно понимать в какой именно мы хотим добавить вызов своего метода. Всего есть 8 групп:

TimeUpdate = 0
Initialization = 1
EarlyUpdate = 2
FixedUpdate = 3
PreUpdate = 4
Update = 5
PreLateUpdate = 6
PostLateUpdate = 7


Использовать проще всего с инжектом при инициализации, но в принципе можно вызывать этот код когда угодно, как и удалять свою систему из обработки:


[RuntimeInitializeOnLoadMethod]
static void Inject() {
var loop = PlayerLoop.GetCurrentPlayerLoop();
var sys = new PlayerLoopSystem {
type = typeof(YourClassName),
updateDelegate = () => Debug.Log("Custom Update")
};
var index = 4; // PreUpdate (см список выше)
loop.subSystemList[index].subSystemList = loop.subSystemList[index].subSystemList.Append(sys).ToArray();
PlayerLoop.SetPlayerLoop(loop);
}


#unity #playerloop
3🔥51👍2



tgoop.com/unsafecsharp/271
Create:
Last Update:

Player Loop

Вместо MonoBehaviour на сцене можно использовать инжект в текущий луп. Для этого нужно понимать в какой именно мы хотим добавить вызов своего метода. Всего есть 8 групп:


TimeUpdate = 0
Initialization = 1
EarlyUpdate = 2
FixedUpdate = 3
PreUpdate = 4
Update = 5
PreLateUpdate = 6
PostLateUpdate = 7


Использовать проще всего с инжектом при инициализации, но в принципе можно вызывать этот код когда угодно, как и удалять свою систему из обработки:


[RuntimeInitializeOnLoadMethod]
static void Inject() {
var loop = PlayerLoop.GetCurrentPlayerLoop();
var sys = new PlayerLoopSystem {
type = typeof(YourClassName),
updateDelegate = () => Debug.Log("Custom Update")
};
var index = 4; // PreUpdate (см список выше)
loop.subSystemList[index].subSystemList = loop.subSystemList[index].subSystemList.Append(sys).ToArray();
PlayerLoop.SetPlayerLoop(loop);
}


#unity #playerloop

BY Unity: Всё, что вы не знали о разработке


Share with your friend now:
tgoop.com/unsafecsharp/271

View MORE
Open in Telegram


Telegram News

Date: |

Add the logo from your device. Adjust the visible area of your image. Congratulations! Now your Telegram channel has a face Click “Save”.! Telegram desktop app: In the upper left corner, click the Menu icon (the one with three lines). Select “New Channel” from the drop-down menu. Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.” With the sharp downturn in the crypto market, yelling has become a coping mechanism for many crypto traders. This screaming therapy became popular after the surge of Goblintown Ethereum NFTs at the end of May or early June. Here, holders made incoherent groaning sounds in late-night Twitter spaces. They also role-played as urine-loving Goblin creatures. During the meeting with TSE Minister Edson Fachin, Perekopsky also mentioned the TSE channel on the platform as one of the firm's key success stories. Launched as part of the company's commitments to tackle the spread of fake news in Brazil, the verified channel has attracted more than 184,000 members in less than a month.
from us


Telegram Unity: Всё, что вы не знали о разработке
FROM American