ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
GameObjectU.hpp
1#pragma once
2
3#include "../../Utils/MonoPtr.hpp"
4
5#include <UnityEngine/GameObject.hpp>
6#include <UnityEngine/Transform.hpp>
7
9
10 namespace _u
11 {
12 using namespace UnityEngine;
13 }
14 namespace _v
15 {
16 using namespace CP_SDK::Utils;
17 }
18
21 {
22 public:
26 inline static void ChangerLayerRecursive(_u::GameObject* p_This, int p_Layer)
27 {
28 if (!_v::IsUnityPtrValid(p_This))
29 return;
30
31 p_This->set_layer(p_Layer);
32
33 auto l_ChildCount = p_This->get_transform()->get_childCount();
34 for (auto l_I = 0; l_I < l_ChildCount; ++l_I)
35 {
36 auto l_Child = p_This->get_transform()->GetChild(l_I)->get_gameObject();
37 if (_v::IsUnityPtrValid(l_Child))
38 ChangerLayerRecursive(l_Child, p_Layer);
39 }
40 }
44 inline static _u::GameObject* FindCommonRoot(_u::GameObject* p_Left, _u::GameObject* p_Right)
45 {
46 if (!_v::IsUnityPtrValid(p_Left) || !_v::IsUnityPtrValid(p_Right))
47 return nullptr;
48
49 auto l_LeftTransform = p_Left->get_transform();
50 while (_v::IsUnityPtrValid(l_LeftTransform))
51 {
52 auto l_RightTransform = p_Right->get_transform();
53 while (_v::IsUnityPtrValid(l_RightTransform))
54 {
55 if (l_LeftTransform == l_RightTransform)
56 return l_LeftTransform->get_gameObject();
57
58 l_RightTransform = l_RightTransform->get_parent();
59 }
60
61 l_LeftTransform = l_LeftTransform->get_parent();
62 }
63
64 return nullptr;
65 }
68 inline static void DestroyChilds(_u::GameObject* p_This)
69 {
70 if (!p_This)
71 return;
72
73 auto l_ChildCount = p_This->get_transform()->get_childCount();
74 for (auto l_I = (l_ChildCount - 1); l_I >= 0; l_I--)
75 {
76 _u::GameObject::Destroy(p_This->get_transform()->GetChild(l_I)->get_gameObject());
77 }
78 }
79
80 };
81
82}
static void DestroyChilds(_u::GameObject *p_This)
Destroy child gameobjects.
static _u::GameObject * FindCommonRoot(_u::GameObject *p_Left, _u::GameObject *p_Right)
Find common root between 2 game objects.
static void ChangerLayerRecursive(_u::GameObject *p_This, int p_Layer)
Change the layer of a GameObject and all his childs.
Quality of life extensions to interact with Unity types.
Definition ColorU.hpp:6
Various platform utils like Delegate/Action/Function/Event system.
Definition Delegate.hpp:8