/// <summary> /// Returns the parent with certain component type. /// </summary> /// <param name="subject">UnityEngine.Transform</param> /// <returns>UnityEngine.Transform</returns> public static UnityEngine.Transform GetTopLvl <T>(UnityEngine.Transform subject) { UnityEngine.Transform s = subject; while (s.parent != null && s.GetComponent <T>() == null) { s = s.parent; } return(s); }
public static bool TryGetComponent<T>(this UnityEngine.Transform monoBehaviour, out T component) { component = default(T); if (monoBehaviour == null) return false; component = monoBehaviour.GetComponent<T>(); if (component != null) return (component.ToString() != null && component.ToString() != "null"); else return false; }
/** レイヤーマスク。全設定。 */ private static void Raw_SetLayerAll(UnityEngine.Transform a_transform, int a_layer_index) { UnityEngine.GameObject t_gameobject = a_transform.GetComponent <UnityEngine.GameObject>(); if (t_gameobject != null) { t_gameobject.layer = a_layer_index; } foreach (UnityEngine.Transform t_transform in a_transform) { Raw_SetLayerAll(t_transform, a_layer_index); } }
public static void SetLayerForAllHierarchy(this UnityEngine.Transform root, UnityEngine.Transform layerSource, System.Type[] filter = null) { if (filter.IsNullOrEmpty()) { root.gameObject.layer = layerSource.gameObject.layer; } else { foreach (var type in filter) { if (!root.GetComponent(type).IsNull()) { root.gameObject.layer = layerSource.gameObject.layer; break; } } } foreach (UnityEngine.Transform child in root) { child.SetLayerForAllHierarchy(layerSource, filter); } }
public static void Register() { if (doNotModify) { return; } object o = null; { UnityEngine.MonoBehaviour v = (UnityEngine.MonoBehaviour)o; v = new UnityEngine.MonoBehaviour(); var p1 = v.tag; v.tag = (System.String)o; var p2 = v.name; v.name = (System.String)o; v.IsInvoking(); v.CancelInvoke(); v.Invoke((System.String)o, (System.Single)o); v.InvokeRepeating((System.String)o, (System.Single)o, (System.Single)o); v.CancelInvoke((System.String)o); v.IsInvoking((System.String)o); v.StartCoroutine((System.String)o); v.StartCoroutine((System.String)o, (System.Object)o); v.StartCoroutine((System.Collections.IEnumerator)o); v.StopCoroutine((System.Collections.IEnumerator)o); v.StopCoroutine((UnityEngine.Coroutine)o); UnityEngine.MonoBehaviour.print((System.Object)o); v.GetComponent((System.Type)o); UnityEngine.Component p3 = (UnityEngine.Component)o; v.TryGetComponent((System.Type)o, out p3); v.GetComponentInChildren((System.Type)o, (System.Boolean)o); v.GetComponentInChildren((System.Type)o); v.GetComponentsInChildren((System.Type)o, (System.Boolean)o); v.GetComponentsInChildren((System.Type)o); v.GetComponentInParent((System.Type)o); v.GetComponentsInParent((System.Type)o, (System.Boolean)o); v.GetComponentsInParent((System.Type)o); v.GetComponents((System.Type)o); v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o); v.CompareTag((System.String)o); v.SendMessageUpwards((System.String)o, (System.Object)o); v.SendMessageUpwards((System.String)o); v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o); v.SendMessage((System.String)o, (System.Object)o); v.SendMessage((System.String)o); v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.BroadcastMessage((System.String)o, (System.Object)o); v.BroadcastMessage((System.String)o); v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.GetInstanceID(); v.GetHashCode(); v.Equals((System.Object)o); v.ToString(); } { UnityEngine.Transform v = (UnityEngine.Transform)o; var p4 = v.position; v.position = (UnityEngine.Vector3)o; var p5 = v.localPosition; v.localPosition = (UnityEngine.Vector3)o; var p6 = v.eulerAngles; v.eulerAngles = (UnityEngine.Vector3)o; var p7 = v.localEulerAngles; v.localEulerAngles = (UnityEngine.Vector3)o; var p8 = v.right; v.right = (UnityEngine.Vector3)o; var p9 = v.up; v.up = (UnityEngine.Vector3)o; var pA = v.forward; v.forward = (UnityEngine.Vector3)o; var pB = v.rotation; v.rotation = (UnityEngine.Quaternion)o; var pC = v.localRotation; v.localRotation = (UnityEngine.Quaternion)o; var pD = v.localScale; v.localScale = (UnityEngine.Vector3)o; var pE = v.parent; v.parent = (UnityEngine.Transform)o; var pF = v.worldToLocalMatrix; var p10 = v.localToWorldMatrix; var p11 = v.root; var p12 = v.lossyScale; var p13 = v.hierarchyCapacity; v.hierarchyCapacity = (System.Int32)o; var p14 = v.hierarchyCount; var p15 = v.tag; v.tag = (System.String)o; var p16 = v.name; v.name = (System.String)o; v.SetParent((UnityEngine.Transform)o); v.SetPositionAndRotation((UnityEngine.Vector3)o, (UnityEngine.Quaternion)o); v.Translate((UnityEngine.Vector3)o, (UnityEngine.Space)o); v.Translate((UnityEngine.Vector3)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o); v.Translate((UnityEngine.Vector3)o, (UnityEngine.Transform)o); v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Transform)o); v.Rotate((UnityEngine.Vector3)o, (UnityEngine.Space)o); v.Rotate((UnityEngine.Vector3)o); v.Rotate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o); v.Rotate((System.Single)o, (System.Single)o, (System.Single)o); v.Rotate((UnityEngine.Vector3)o, (System.Single)o, (UnityEngine.Space)o); v.Rotate((UnityEngine.Vector3)o, (System.Single)o); v.RotateAround((UnityEngine.Vector3)o, (UnityEngine.Vector3)o, (System.Single)o); v.LookAt((UnityEngine.Transform)o, (UnityEngine.Vector3)o); v.LookAt((UnityEngine.Transform)o); v.LookAt((UnityEngine.Vector3)o, (UnityEngine.Vector3)o); v.LookAt((UnityEngine.Vector3)o); v.TransformDirection((UnityEngine.Vector3)o); v.TransformDirection((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformDirection((UnityEngine.Vector3)o); v.InverseTransformDirection((System.Single)o, (System.Single)o, (System.Single)o); v.TransformVector((UnityEngine.Vector3)o); v.TransformVector((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformVector((UnityEngine.Vector3)o); v.InverseTransformVector((System.Single)o, (System.Single)o, (System.Single)o); v.TransformPoint((UnityEngine.Vector3)o); v.TransformPoint((System.Single)o, (System.Single)o, (System.Single)o); v.InverseTransformPoint((UnityEngine.Vector3)o); v.InverseTransformPoint((System.Single)o, (System.Single)o, (System.Single)o); v.Find((System.String)o); v.GetEnumerator(); v.GetComponent((System.Type)o); UnityEngine.Component p17 = (UnityEngine.Component)o; v.TryGetComponent((System.Type)o, out p17); v.GetComponentInChildren((System.Type)o, (System.Boolean)o); v.GetComponentInChildren((System.Type)o); v.GetComponentsInChildren((System.Type)o, (System.Boolean)o); v.GetComponentsInChildren((System.Type)o); v.GetComponentInParent((System.Type)o); v.GetComponentsInParent((System.Type)o, (System.Boolean)o); v.GetComponentsInParent((System.Type)o); v.GetComponents((System.Type)o); v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o); v.CompareTag((System.String)o); v.SendMessageUpwards((System.String)o, (System.Object)o); v.SendMessageUpwards((System.String)o); v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o); v.SendMessage((System.String)o, (System.Object)o); v.SendMessage((System.String)o); v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.BroadcastMessage((System.String)o, (System.Object)o); v.BroadcastMessage((System.String)o); v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o); v.GetInstanceID(); v.GetHashCode(); v.Equals((System.Object)o); v.ToString(); } }
public static bool Prefix(ref CinematicModeTrigger __instance, GUIHand hand) { bool bLog = false; string handText = __instance.handText; if (msgTimer > 0) { msgTimer--; } else { bLog = bDebug && Logger.DebugLogsEnabled; if (bLog) { if (bLog) { ErrorMessage.AddMessage($"CinematicModeTrigger_OnHandHover_Patch.Prefix() running, handText = {handText}"); } msgTimer = 30; } } if (handText != "EnterCyclops" && handText != "LeaveCyclops") { return(true); } if (!__instance.showIconOnHandHover) { if (bLog) { ErrorMessage.AddMessage($"showIconOnHandHover == false"); } return(true); } if (PlayerCinematicController.cinematicModeCount > 0) { if (bLog) { ErrorMessage.AddMessage($"cinematicModeCount > 0"); } return(true); } if (string.IsNullOrEmpty(__instance.handText)) { if (bLog) { ErrorMessage.AddMessage($"string handText IsNullOrEmpty"); } return(true); } // transform.parent will be the CyclopsMeshAnimated; we need to go up one more level to get the Cyclops-MainPrefab, at which point we can get at the SubRoot UnityEngine.Transform transformGrandparent = __instance.transform.parent.parent; SubRoot subRoot = null; if (transformGrandparent != null) { subRoot = transformGrandparent.GetComponent <SubRoot>(); } else { if (bLog) { ErrorMessage.AddMessage($"Couldn't get transformRoot in __instance"); } return(true); } if (subRoot == null) { if (bLog) { ErrorMessage.AddMessage($"Couldn't get SubRoot in transformRoot"); } return(true); } string subName = subRoot.GetSubName(); string language = Language.main.GetCurrentLanguage(); //if (bLog) ErrorMessage.AddMessage($"calling TryGetVehiclePrompt with parameters initialKey='{handText}', language='{language}', VehicleName='{subName}'"); if (Main.TryGetVehiclePrompt(handText, Language.main.GetCurrentLanguage(), subName, out string prompt)) { if (bLog) { ErrorMessage.AddMessage($"TryGetVehiclePrompt returned true with value for prompt of '{prompt}'"); } #if SUBNAUTICA_STABLE HandReticle.main.SetInteractText(prompt); #elif BELOWZERO HandReticle.main.SetText(HandReticle.TextType.Hand, prompt, true); #endif HandReticle.main.SetIcon(HandReticle.IconType.Hand, 1f); return(false); } else { if (bLog) { ErrorMessage.AddMessage($"TryGetVehiclePrompt returned false"); } } return(true); }
public void InitComponent(Transform baseTF) { _armature = baseTF.GetComponent <UnityArmatureComponent>(); }