-
-
Save zzzz465/0729258474dc90b6397d3ae9adc247b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using UnityEngine.SceneManagement; | |
using UnityEngine; | |
using Xft; | |
using System.Reflection; | |
namespace CustomTailor | |
{ | |
class test | |
{ | |
public static void onSceneLoaded(Scene CurrentScene, LoadSceneMode loadSceneMode) | |
{ | |
if (CurrentScene.name == "GameCore") | |
{ | |
Console.WriteLine("onSceneLoaded -> CurrentScene.name == Gamecore"); | |
GameObject GameCore = CurrentScene.GetRootGameObjects()[0]; //GameCore를 줌 | |
Component Saber = GameCore.GetComponent<Saber>(); | |
Transform origin = GameCore.transform.Find("Origin"); | |
Transform VRGameCore = origin.Find("VRGameCore"); // 여기안에, SaberManager, LeftSaber, RightSaber가 들어가 있음 | |
Transform LeftSaber = VRGameCore.Find("LeftSaber"); | |
//Console.WriteLine(LeftSaber.name); | |
//Child는 계층 탭에서 볼수있는 부모,자식 관계를 말하는 것이고, Component는 각 오브젝트에 있는 Transform, Rigidbody 등등을 말함 | |
Console.WriteLine("Get all components in Leftsaber/Transform"); | |
Saber saber = LeftSaber.GetComponent<Saber>(); | |
// LeftSaber.GetComponents(typeof(Component)) 여기 안에는 UnityEngine.Transform, VRController, UnityEngine.BoxCollider, UnityEngine.Rigidbody, Saber, SaberTypeObject, SaberModelContainer 가 있음 | |
Saber[] sabers = Resources.FindObjectsOfTypeAll<Saber>(); | |
foreach(Saber Sab in sabers) | |
{ | |
Console.WriteLine(Sab.gameObject.name); | |
Console.WriteLine(Sab.name); | |
} | |
foreach(object obj in Resources.FindObjectsOfTypeAll<SaberWeaponTrail>().ToArray<SaberWeaponTrail>()) | |
{ | |
object value = 500; | |
obj.GetType().GetField("_maxFrame", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(obj, value); | |
Console.WriteLine(obj.GetType().GetField("_maxFrame", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj).ToString()); | |
obj.GetType().GetField("_granularity", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(obj, (int)value * 3); | |
} | |
/* | |
Console.WriteLine(components.Length.ToString()); | |
//Console.WriteLine("Get all components in LeftSaber"); | |
foreach(var x in components) | |
{ | |
Console.WriteLine(x.ToString() + " - "); | |
}*/ | |
var LeftSaberFields = LeftSaber.GetType().GetFields(); | |
foreach (var field in LeftSaberFields) | |
{ | |
Console.WriteLine(field.Name); | |
} | |
/* | |
int testTrailLength = 100; | |
ReflectionUtil.SetPrivateField(xweapontrail, "_maxFrame", testTrailLength); | |
ReflectionUtil.SetPrivateField(xweapontrail, "_granularity", testTrailLength * 3); | |
Console.WriteLine("modify privateField value success!"); | |
*/ | |
/* | |
for (int count = 0; count < index; count++) | |
{ | |
Console.WriteLine("count = " + count.ToString()); | |
try { Console.WriteLine("name : " + LeftSaber.GetChild(count)); } | |
catch { Console.WriteLine("error, " + LeftSaber.transform.name); } | |
}*/ | |
} | |
} | |
//public static void ApplyModify() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment