Поговорили о том как и где использовать UI Toolkit
#record #stream
Добро пожаловать в канал Unity: Всё, что вы не знали о разработке! Если вы увлечены миром разработки игр в Unity, то этот канал точно для вас. Здесь вы найдете множество полезных советов и интересных кейсов от автора канала, Alex Silaev, который является CTO в компании Zillion Whales и создателем игры Mushroom Wars 2. В канале вы сможете узнать о последних тенденциях в мире разработки в Unity, а также получить лайфхаки и решения от профессионала. Alex Silaev будет делиться своим опытом и знаниями с вами, помогая вам стать успешным разработчиком в Unity. Присоединяйтесь к нам и узнайте всё, что нужно знать о разработке в Unity!
08 Feb, 12:07
04 Feb, 11:20
08 Dec, 08:42
if (obj.isCreated == false) {
obj = new Obj();
}
lock (lockObj) {
if (obj.isCreated == false) {
obj = new Obj();
}
}
if (obj.isCreated == false) {
lock (lockObj) {
if (obj.isCreated == false) {
obj = new Obj();
}
}
}
05 Dec, 06:44
IJobParallelForAspect<T..n>
IJobParallelForComponents<T..n>
public struct Job : IJobParallelForComponents<C1, C2> {
public void Execute(in JobInfo jobInfo, in Ent ent, ref C1 c1, ref C2 c2) {...}
}
public struct JobDebugDataXXX {
[NativeDisableUnsafePtrRestriction] public MyJob jobData;
[NativeDisableUnsafePtrRestriction] public CommandBuffer* buffer;
public RefRW<C1> c0;
public SafetyComponentContainerRO<C1> C1;
public SafetyComponentContainerWO<C2> C2;
public SafetyComponentContainerRO<ParentComponent> ParentComponent;
}
void Execute(in JobInfo jobInfo, in Ent ent, ref C1 c1) {
ent.GetParent().Get<C2>().data = c1.data;
}
19 Nov, 09:35
public interface I1 {}
public interface I2 {}
public class MyClass {
public void Method<T>() where T : struct, I1 {}
public void Method<T>() where T : struct, I2 {}
}
Method1<T>
Method2<T>
public interface I1 {}
public interface I2 {}
public class MyClass {}
public static class MyClassExt1 {
public static void Method<T>(this MyClass obj) where T : struct, I1 {}
}
public static class MyClassExt2 {
public static void Method<T>(this MyClass obj) where T : struct, I2 {}
}
11 Nov, 12:49
var temp = a;
a = b;
b = temp;
(a, b) = (b, a);
12 Oct, 11:36
08 Oct, 08:31
VisualElement CreatePropertyGUI(SerializedProperty property) {
...
}
private void CreateGUI() {
...
}
VisualElement CreateInspectorGUI() {
...
}
Label myLabel;
VisualElement CreateInspectorGUI() {
// Создаем свой контейнер
var myRoot = new VisualElement();
// Добавляем файл со стилями
myRoot.styleSheets.Add(Resources.Load<StyleSheet>("MyStyle"));
// Создаем label
var label = new Label("Hello World");
label.AddToClassList("my-label");
this.myLabel = label;
// Добавляем в иерархию
myRoot.Add(label);
// Возвращаем корневой объект
return myRoot;
}
void UpdateLabel() {
// Просто обновляем текст у объекта
this.myLabel.text = "New text";
}
// Наводим всякие красивости
.my-label {
font-size: 20px;
border-radius: 5px;
background-color: red;
}
07 Oct, 05:25
Method(static () => …);
06 Oct, 07:44
value = int.MaxValue;
checked {
value += 1; // тут мы получим исключение
}
value = int.MaxValue;
unchecked {
value += 1; // тут исключения не будет, число будет равно минимальному значению
}
return checked(value + 1);
03 Oct, 06:25
struct MyStruct {
public int a;
public byte b;
public int c;
public byte d;
}
public int a; // 4 байта
public byte b; // 1 байт
public int c; // 4 байта
public byte d; // 1 байт
public byte b; // 4 байта при Pack = 4
public byte b; // 1 байт при Pack = 1
public int a; // 4 байта
public byte b; // 4 байта
public int c; // 4 байта
public byte d; // 4 байта
public int a; // 4 байта
public int c; // 4 байта
public byte b; // 1 байт
public byte d; // 1 байт
[StructLayout(LayoutKind.Sequential, Pack = 4)]
struct MyStruct {
public int a;
public byte b;
public int c;
public byte d;
}
[StructLayout(LayoutKind.Sequential, Size = 10)]
struct MyStruct {
public int a;
public int c;
public byte b;
public byte d;
}
[StructLayout(LayoutKind.Explicit)]
struct MyStruct {
[FieldOffset(0)]
public int a;
[FieldOffset(4)]
public int c;
[FieldOffset(0)]
public long b;
}
09 Sep, 11:21
09 Sep, 11:21
16 Aug, 10:00
public class RAM : MonoBehaviour {
public object[] objects;
}
public class Processor : MonoBehaviour {
public object currentObject;
}
var arr = new int[1000];
for (int i = 0; i < arr.Length; ++i) {
arr[i] // обращаемся к массиву
}
var arr2 = new int[arr.Length];
for (int i = 0; i < arr.Length; ++i) {
arr[i] // обращаемся к массиву
arr2[i] // обращаемся ко второму массиву
}
struct MyStruct {
int a1;
int a2;
}
var arr = new MyStruct[1000];
for (int i = 0; i < arr.Length; ++i) {
arr[i].a1 // обращаемся к массиву и получаем a1
arr[i].a2 // обращаемся к массиву и получаем a2
}
arr = new int[10]; // Допустим, мы делаем 10 потоков
Thread(int threadIndex) {
++arr[threadIndex]; // обращаемся к своему индексу для каждого потока
}
12 Jun, 20:32
30 Apr, 01:39
27 Apr, 18:35
27 Apr, 03:55
26 Apr, 08:56
var nextPoint = points[index];
if ((nextPoint - position).sqrMagnitude <= MIN_DISTANCE_SQR) {
++index;
if (index >= points.Length) {
// Мы дошли до конца пути
return;
}
}
position = Vector3.MoveTowards(position, nextPoint, dt * speed);
-[]--[]--[]--[]--[]
---------------[] // Этот персонаж дойдет до конца быстрее, чем первый
var distance = speed * dt;
while (distance > 0f) {
var nextNodePos = points[index];
var distanceToNextNode = (nextNodePos - currentPos).magnitude;
if (distance >= distanceToNextNode) {
distance -= distanceToNextNode;
currentPos = nextNodePos;
++index;
if (index >= points.Length) break;
continue;
}
var direction = (nextNodePos - currentPos).normalized;
currentPos = direction * distance;
break;
}
25 Apr, 13:34
int Method(IInterface obj) {
...
return obj.Calc();
}
public struct S1 : IInterface {…}
public struct S2 : IInterface {…}
void Update() {
Method(new S1());
…
Method(new S2());
}
interface IInterface {
int Calc();
}
19 Apr, 18:52
ENABLE_SHADER_DEBUG_PRINT
в проекте (для HDRP, кажется, оно и так будет работать).// #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ShaderDebugPrint.hlsl"
ShaderDebugPrintMouseButtonOver(int2(input.positionSS.xy), ShaderDebugTag('S','m','o', 't'), fragData.smoothness);
Frame #270497: Smot float4(0.1f, 0.2f, 0.3f, 0.4f)
- ну, или что у вас там в вашем цвете. 13 Feb, 20:57
11 Feb, 09:40
08 Feb, 09:38
04 Feb, 22:13
30 Jan, 12:01