本文整理汇总了C#中Transform.GetComponentsInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.GetComponentsInChildren方法的具体用法?C# Transform.GetComponentsInChildren怎么用?C# Transform.GetComponentsInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.GetComponentsInChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Flip
public void Flip()
{
_enemies = GameObject.Find("Enemies").transform;
Physics.gravity = new Vector3(0, -Physics.gravity.y, 0);
if (!_flipped){
FMOD_StudioSystem.instance.PlayOneShot("event:/GravitySwitcherUp", transform.position);
_qTo = _qFlip;
_qToCamera = _qFlipCamera;
_flipped = true;
_flyingEnemyScripts = _enemies.GetComponentsInChildren<EnemyClass>();
cameraFollowScript.Height -= cameraFollowScript.Height;
}
else {
FMOD_StudioSystem.instance.PlayOneShot("event:/GravitySwitcherDown", transform.position);
_qTo = Quaternion.identity;
_qToCamera = Quaternion.identity;
_flipped = false;
_flyingEnemyScripts = _enemies.GetComponentsInChildren<EnemyClass>();
cameraFollowScript.Height -= cameraFollowScript.Height;
}
_qToEnemy = _qTo;
//_qTo.y = _player.rotation.y;
Done = false;
UpdateRotationEnemy();
}
示例2: Awake
void Awake()
{
m_instance = this;
m_myTransform = transform;
FillFullNameData(m_myTransform);
m_tranRankingUITabList = m_myTransform.FindChild(m_widgetToFullName["RankingUITabList"]);
m_tabMogoSingleButtonList = m_tranRankingUITabList.GetComponentsInChildren<MogoSingleButtonList>(true)[0];
m_tabMogoListImproved = m_tranRankingUITabList.GetComponentsInChildren<MogoListImproved>(true)[0];
m_tranRankingUIMainRankDataList = m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankDataList"]);
m_mainRankDataMogoSingleButtonList = m_tranRankingUIMainRankDataList.GetComponentsInChildren<MogoSingleButtonList>(true)[0];
m_mainRankDataMogoListImproved = m_tranRankingUIMainRankDataList.GetComponentsInChildren<MogoListImproved>(true)[0];
m_tranRankingUIPlayerRankDataList = m_myTransform.FindChild(m_widgetToFullName["RankingUIPlayerRankDataList"]);
m_playerRankDataMogoListImproved = m_tranRankingUIPlayerRankDataList.GetComponentsInChildren<MogoListImproved>(true)[0];
m_lblRankingUIBtnBecameFSText = m_myTransform.FindChild(m_widgetToFullName["RankingUIBtnBecameFSText"]).GetComponentsInChildren<UILabel>(true)[0];
m_listRankingUIMainRankTitle.Add(m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankTitle1"]).GetComponentsInChildren<UILabel>(true)[0]);
m_listRankingUIMainRankTitle.Add(m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankTitle2"]).GetComponentsInChildren<UILabel>(true)[0]);
m_listRankingUIMainRankTitle.Add(m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankTitle3"]).GetComponentsInChildren<UILabel>(true)[0]);
m_listRankingUIMainRankTitle.Add(m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankTitle4"]).GetComponentsInChildren<UILabel>(true)[0]);
m_listRankingUIMainRankTitle.Add(m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankTitle5"]).GetComponentsInChildren<UILabel>(true)[0]);
for (int i = 0; i < m_listRankingUIMainRankTitle.Count; i++)
{
m_listRankingUIMainRankTitle[i].effectStyle = UILabel.Effect.None;
m_listRankingUIMainRankTitle[i].color = new Color32(63, 27, 4, 255);
}
m_lblRankingUIMyRankText = m_myTransform.FindChild(m_widgetToFullName["RankingUIMyRankText"]).GetComponentsInChildren<UILabel>(true)[0];
m_goGORankingUIMainRankData = m_myTransform.FindChild(m_widgetToFullName["GORankingUIMainRankData"]).gameObject;
m_goGORankingUIPanelPlayerInfo = m_myTransform.FindChild(m_widgetToFullName["GORankingUIPanelPlayerInfo"]).gameObject;
m_goGORankingUIPanelPlayerEquip = m_myTransform.FindChild(m_widgetToFullName["GORankingUIPanelPlayerEquip"]).gameObject;
m_goRankingUIModelShowCase = m_myTransform.FindChild(m_widgetToFullName["RankingUIModelShowCase"]).gameObject;
m_modelShowCase = m_goRankingUIModelShowCase.AddComponent<ModelShowCase>();
m_modelShowCase.left = m_myTransform.FindChild(m_widgetToFullName["RankingUIModelViewTopLeft"]);
m_modelShowCase.right = m_myTransform.FindChild(m_widgetToFullName["RankingUIModelViewBottomRight"]);
m_goRankingUIMyRankShowReward = m_myTransform.FindChild(m_widgetToFullName["RankingUIMyRankShowReward"]).gameObject;
m_goGORankingUIWaitingTip = m_myTransform.FindChild(m_widgetToFullName["GORankingUIWaitingTip"]).gameObject;
m_goRankingUIMainRankDataArrow = m_myTransform.FindChild(m_widgetToFullName["RankingUIMainRankDataArrow"]).gameObject;
m_goPanelPlayerEquip = m_myTransform.FindChild(m_widgetToFullName["PanelPlayerEquip"]).gameObject;
m_panelPlayerEquip = m_goPanelPlayerEquip.AddComponent<PanelPlayerEquip>();
m_myTransform.FindChild(m_widgetToFullName["RankingUIBtnClose"]).gameObject.AddComponent<RankingUIButton>();
m_myTransform.FindChild(m_widgetToFullName["RankingUIBtnBackToRank"]).gameObject.AddComponent<RankingUIButton>();
m_myTransform.FindChild(m_widgetToFullName["RankingUIBtnBecameFS"]).gameObject.AddComponent<RankingUIButton>();
m_myTransform.FindChild(m_widgetToFullName["RankingUIMyRankShowReward"]).gameObject.AddComponent<RankingUIButton>();
Initialize();
}
示例3: Awake
void Awake()
{
m_myTransform = transform;
Initialize();
m_lblText = m_myTransform.GetComponentsInChildren<UILabel>(true)[0];
m_tweenAlpha = m_myTransform.GetComponentsInChildren<TweenAlpha>(true)[0];
m_tweenPosition = m_myTransform.GetComponentsInChildren<TweenPosition>(true)[0];
}
示例4: Fade
IEnumerator Fade(Transform obj)
{
for (int i = 12; i > -1; i--) {
foreach (Image image in obj.GetComponentsInChildren<Image> ())
image.color = new Color (image.color.r, image.color.g, image.color.b, i/13f);
foreach (Text text in obj.GetComponentsInChildren<Text> ())
text.color = new Color (text.color.r, text.color.g, text.color.b, i/13f);
yield return null;
}
obj.gameObject.SetActive (false);
}
示例5: CalculateAbsoluteWidgetBounds
public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
{
UIWidget[] componentsInChildren = trans.GetComponentsInChildren<UIWidget>();
if (componentsInChildren.Length == 0)
{
return new Bounds(trans.position, Vector3.zero);
}
Vector3 rhs = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
Vector3 vector2 = new Vector3(float.MinValue, float.MinValue, float.MinValue);
int index = 0;
int length = componentsInChildren.Length;
while (index < length)
{
UIWidget widget = componentsInChildren[index];
if (widget.enabled)
{
Vector3[] worldCorners = widget.worldCorners;
for (int i = 0; i < 4; i++)
{
vector2 = Vector3.Max(worldCorners[i], vector2);
rhs = Vector3.Min(worldCorners[i], rhs);
}
}
index++;
}
Bounds bounds = new Bounds(rhs, Vector3.zero);
bounds.Encapsulate(vector2);
return bounds;
}
示例6: Awake
void Awake()
{
m_transform = transform;
var ssList = m_transform.GetComponentsInChildren<UISprite>(true);
if (m_bgUp == null)
{
m_bgUp = ssList[0].gameObject;
}
if (m_bgUp != null)
{
m_bgUpSpriteName = m_bgUp.transform.GetComponentsInChildren<UISprite>(true)[0].spriteName;
}
if (m_bgDown == null)
{
m_bgDown = ssList[1].gameObject;
}
m_lblText = m_transform.GetComponentInChildren<UILabel>();
if (IsSmart)
{
m_transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
BoxCollider bc = m_transform.GetComponent<BoxCollider>();
bc.center = Vector3.zero;
m_bgUp.transform.localScale = new Vector3(bc.size.x, bc.size.y, 1.0f);
m_bgDown.transform.localScale = new Vector3(bc.size.x, bc.size.y, 1.0f);
}
}
示例7: Awake
void Awake()
{
m_myTransform = transform;
m_instance = m_myTransform.GetComponentsInChildren<TeachUIViewManager>(true)[0];
m_goPanel = gameObject;
m_camTeachUI = m_myTransform.parent.parent.GetComponentsInChildren<Camera>(true)[0];
m_goMaskBG = m_myTransform.FindChild("TeachUIMaskBG").gameObject;
m_goFingerAnim = m_myTransform.FindChild("TeachUIFingerAnim").gameObject;
m_goTip = m_myTransform.FindChild("TeachUITip").gameObject;
m_goTipBL = m_myTransform.FindChild("TeachUIFingerAnim/TeachUITipBL").gameObject;
m_goTipBR = m_myTransform.FindChild("TeachUIFingerAnim/TeachUITipBR").gameObject;
m_goTipTL = m_myTransform.FindChild("TeachUIFingerAnim/TeachUITipTL").gameObject;
m_goTipTR = m_myTransform.FindChild("TeachUIFingerAnim/TeachUITipTR").gameObject;
m_lblTipText = m_goTip.transform.FindChild("TeachUITipText").GetComponentsInChildren<UILabel>(true)[0];
m_goLeftArr = m_myTransform.FindChild("TeachUITip/TeachUITipArrLeft").gameObject;
m_goRightArr = m_myTransform.FindChild("TeachUITip/TeachUITipArrRight").gameObject;
//m_goTeachUICamera = m_myTransform.parent.parent.gameObject;
Initialize();
}
示例8: FindInChildren
public static Transform FindInChildren(Transform go, string name)
{
foreach (Transform x in go.GetComponentsInChildren<Transform>())
if (x.gameObject.name == name)
return x;
return null;
}
示例9: ChangeMaterialForAllChild
public static void ChangeMaterialForAllChild(Transform b, Material mat, string[] expect = null)
{
Transform[] allChildren = b.GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren)
{
if (child.GetComponent<ParticleSystem>() == null)
{
if (expect == null)
{
ChangeMaterialForChild(child, mat);
}
else
{
bool ok = true;
foreach (string s in expect)
{
if (!string.IsNullOrEmpty(s) && s.Equals(child.name))
{
ok = false;
break;
}
}
if (ok)
ChangeMaterialForChild(child, mat);
}
}
}
}
示例10: CalculateAbsoluteWidgetBounds
/// <summary>
/// Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
/// </summary>
public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
{
UIWidget[] widgets = trans.GetComponentsInChildren<UIWidget>() as UIWidget[];
if (widgets.Length == 0) return new Bounds(trans.position, Vector3.zero);
Vector3 vMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
Vector3 vMax = new Vector3(float.MinValue, float.MinValue, float.MinValue);
for (int i = 0, imax = widgets.Length; i < imax; ++i)
{
UIWidget w = widgets[i];
if (!w.enabled) continue;
Vector3[] corners = w.worldCorners;
for (int j = 0; j < 4; ++j)
{
vMax = Vector3.Max(corners[j], vMax);
vMin = Vector3.Min(corners[j], vMin);
}
}
Bounds b = new Bounds(vMin, Vector3.zero);
b.Encapsulate(vMax);
return b;
}
示例11: Bake
public static void Bake(Transform rootObject)
{
List<UnityEngine.Object> undoObjects = new List<UnityEngine.Object>();
undoObjects.AddRange( rootObject.GetComponentsInChildren<Transform>() );
undoObjects.AddRange( rootObject.GetComponentsInChildren<tk2dTextMesh>() );
undoObjects.AddRange( rootObject.GetComponentsInChildren<tk2dBaseSprite>() );
MeshFilter[] meshFilters = rootObject.GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter mf in meshFilters) {
if (mf.sharedMesh != null) {
undoObjects.Add( mf.sharedMesh );
}
}
tk2dUndo.RecordObjects(undoObjects.ToArray(), "Bake Scale");
BakeRecursive(rootObject, Vector3.one);
}
示例12: CalculateAbsoluteWidgetBounds
/// <summary>
/// Calculate the combined bounds of all widgets attached to the specified game object or its children (in world space).
/// </summary>
public static Bounds CalculateAbsoluteWidgetBounds(Transform trans)
{
UIWidget[] widgets = trans.GetComponentsInChildren<UIWidget>() as UIWidget[];
Bounds b = new Bounds(trans.transform.position, Vector3.zero);
bool first = true;
foreach (UIWidget w in widgets)
{
Vector2 size = w.relativeSize;
Vector2 offset = w.pivotOffset;
float x = (offset.x + 0.5f) * size.x;
float y = (offset.y - 0.5f) * size.y;
size *= 0.5f;
Transform wt = w.cachedTransform;
Vector3 v0 = wt.TransformPoint(new Vector3(x - size.x, y - size.y, 0f));
// 'Bounds' can never start off with nothing, apparently, and including the origin point is wrong.
if (first)
{
first = false;
b = new Bounds(v0, Vector3.zero);
}
else
{
b.Encapsulate(v0);
}
b.Encapsulate(wt.TransformPoint(new Vector3(x - size.x, y + size.y, 0f)));
b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y - size.y, 0f)));
b.Encapsulate(wt.TransformPoint(new Vector3(x + size.x, y + size.y, 0f)));
}
return b;
}
示例13: Awake
void Awake()
{
m_instance = this;
m_myTransform = transform;
FillFullNameData(m_myTransform);
Camera camera = GameObject.Find("MogoMainUI").transform.FindChild("Camera").GetComponentsInChildren<Camera>(true)[0];
m_camActivityGridList = FindTransform("TimeLimitActivityGridListCamera").GetComponentsInChildren<Camera>(true)[0];
m_camActivityGridList.GetComponentsInChildren<UIViewport>(true)[0].sourceCamera = camera;
m_dragableCameraActivityGridList = m_camActivityGridList.GetComponentsInChildren<MyDragableCamera>(true)[0];
m_dragableCameraActivityGridList.LeftArrow = FindTransform("TimeLimitActivityUIActivityListArrowL").gameObject;
m_dragableCameraActivityGridList.RightArrow = FindTransform("TimeLimitActivityUIActivityListArrowR").gameObject;
m_goActivityGridList = FindTransform("TimeLimitActivityGridList").gameObject;
m_goTimeLimitActivityUIActivityListUI = FindTransform("TimeLimitActivityUIActivityList").gameObject;
m_goGOTimeLimitActivityUIActivityListPage = FindTransform("GOTimeLimitActivityUIActivityListPage").gameObject;
m_goTimeLimitActivityUIActivityInfoListUI = FindTransform("TimeLimitActivityUIActivityInfoList").gameObject;
m_tranTimeLimitActivityInfoGridList = FindTransform("TimeLimitActivityInfoGridList");
m_infoGridListMogoListImproved = m_tranTimeLimitActivityInfoGridList.GetComponentsInChildren<MogoListImproved>(true)[0];
m_infoGridListMogoListImproved.LeftArrow = FindTransform("TimeLimitActivityUIActivityInfoArrowL").gameObject;
m_infoGridListMogoListImproved.RightArrow = FindTransform("TimeLimitActivityUIActivityInfoArrowR").gameObject;
m_timeLimitActivityGridListCameraFX = FindTransform("TimeLimitActivityGridListCameraFX").GetComponentsInChildren<Camera>(true)[0];
m_timeLimitActivityGridListCameraFX.GetComponentsInChildren<UIViewport>(true)[0].sourceCamera = camera;
m_goTimeLimitActivityGridListParticleAnimRoot = FindTransform("TimeLimitActivityGridListParticleAnimRoot").gameObject;
m_goTimeLimitActivityInfoGridListFx = FindTransform("TimeLimitActivityInfoGridListFx").gameObject;
Initialize();
EventDispatcher.TriggerEvent(Events.OperationEvent.GetActivityMessage);
}
示例14: Awake
void Awake()
{
Instance = this;
base.Init();
m_tab = GetUIChild("EquipExchangeTab").GetComponent<MogoSingleButtonList>();
Transform listRoot = GetUIChild("EquipExchangeEquipList");
m_tranDragableCamera = GetUIChild("EquipExchangeEquipListCamera");
m_dragableCamera = m_tranDragableCamera.GetComponentsInChildren<MyDragableCamera>(true)[0];
m_dragableCamera.LeftArrow = GetUIChild("EquipExchangeArrowLeft").gameObject;
m_dragableCamera.RightArrow = GetUIChild("EquipExchangeArrowRight").gameObject;
Transform dragCameraBegin = GetUIChild("EquipExchangeEquipListCameraPosBegin");
GetUIChild("EquipExchangeContainerCloseBtn").gameObject.AddComponent<MogoUIListener>().MogoOnClick = () => { Hide(); };
m_listView = new MogoListView(m_tranDragableCamera, listRoot, dragCameraBegin, GRID_PREFAB_NAME,
true, GRID_GAP, GRID_NUM_PER_PAGE, m_objList);
m_lblGoldNum = GetUIChild("EquipExchangeResourceGoldNumLbl").GetComponent<UILabel>();
m_lblMaterilNum = GetUIChild("EquipExchangeResourceDiamondNumLbl").GetComponent<UILabel>();
m_imgMaterial = GetUIChild("EquipExchangeResourceDiamondIcon").GetComponent<UISprite>();
GetUIChild("EquipExchangeTabBtn1").gameObject.AddComponent<MogoUIListener>().MogoOnClick = () =>
{
if (OnTabSelect != null) OnTabSelect(0);
};
GetUIChild("EquipExchangeTabBtn2").gameObject.AddComponent<MogoUIListener>().MogoOnClick = () =>
{
if (OnTabSelect != null) OnTabSelect(1);
};
gameObject.SetActive(false);
}
示例15: MaxBoundsExtent
private float m_ZoomAmountMultiplier = 2; // a multiplier for the FOV amount. The default of 2 makes the field of view twice as wide as required to fit the target.
#endregion Fields
#region Methods
public static float MaxBoundsExtent(Transform obj, bool includeEffects)
{
// get the maximum bounds extent of object, including all child renderers,
// but excluding particles and trails, for FOV zooming effect.
var renderers = obj.GetComponentsInChildren<Renderer>();
Bounds bounds = new Bounds();
bool initBounds = false;
foreach (Renderer r in renderers)
{
if (!((r is TrailRenderer) || (r is ParticleRenderer) || (r is ParticleSystemRenderer)))
{
if (!initBounds)
{
initBounds = true;
bounds = r.bounds;
}
else
{
bounds.Encapsulate(r.bounds);
}
}
}
float max = Mathf.Max(bounds.extents.x, bounds.extents.y, bounds.extents.z);
return max;
}