當前位置: 首頁>>代碼示例>>C#>>正文


C# Component.GetComponents方法代碼示例

本文整理匯總了C#中UnityEngine.Component.GetComponents方法的典型用法代碼示例。如果您正苦於以下問題:C# Component.GetComponents方法的具體用法?C# Component.GetComponents怎麽用?C# Component.GetComponents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Component的用法示例。


在下文中一共展示了Component.GetComponents方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: getSpriteMask

	private static SpriteMask getSpriteMask (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMask> ();
#else
		t.GetComponents <SpriteMask> (maskComponents);
		SpriteMask sm = maskComponents.Count == 1 ? maskComponents [0] : null;
		maskComponents.Clear ();
		return sm;
#endif
	}
開發者ID:masyl,項目名稱:bolt,代碼行數:11,代碼來源:SpriteMask.cs

示例2: GetObserver

    /// <summary>
    /// Helper function that returns the observer for the specified component.
    /// </summary>
    public static NetworkView GetObserver(Component comp)
    {
        NetworkView[] views = comp.GetComponents<NetworkView>();

        foreach (NetworkView view in views)
        {
            if (view.observed == comp && view.stateSynchronization != NetworkStateSynchronization.Off)
            {
                return view;
            }
        }
        return null;
    }
開發者ID:Greigy,項目名稱:TheGame,代碼行數:16,代碼來源:NetworkManager.cs

示例3: getRenderer

	private static Renderer getRenderer (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <Renderer> ();
#else
		t.GetComponents <Renderer> (rendererComponents);
		Renderer r = rendererComponents.Count > 0 ? rendererComponents [0] : null;
		rendererComponents.Clear ();
		return r;
#endif
	}
開發者ID:masyl,項目名稱:bolt,代碼行數:11,代碼來源:SpriteMask.cs

示例4: getMaskingComponent

	private static SpriteMaskingComponent getMaskingComponent (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMaskingComponent> ();
#else
		t.GetComponents <SpriteMaskingComponent> (maskingComponents);
		SpriteMaskingComponent smc = maskingComponents.Count == 1 ? maskingComponents [0] : null;
		maskingComponents.Clear ();
		return smc;
#endif
	}
開發者ID:ChubbRck,項目名稱:SFB,代碼行數:11,代碼來源:SpriteMask.cs

示例5: hasSkipMasking

	private static bool hasSkipMasking (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SkipMasking> () != null;
#else
		t.GetComponents <SkipMasking> (skipMaskingComponents);
		bool b = skipMaskingComponents.Count > 0;
		skipMaskingComponents.Clear ();
		return b;
#endif
	}
開發者ID:ChubbRck,項目名稱:SFB,代碼行數:11,代碼來源:SpriteMask.cs

示例6: hasMaskingPart

	private static bool hasMaskingPart (Component t)
	{
#if BEFORE_4_6
		return t.GetComponent <SpriteMaskingPart> () != null;
#else
		t.GetComponents <SpriteMaskingPart> (maskingPartComponents);
		bool b = maskingPartComponents.Count > 0;
		maskingPartComponents.Clear ();
		return b;
#endif
	}
開發者ID:ChubbRck,項目名稱:SFB,代碼行數:11,代碼來源:SpriteMask.cs

示例7: FindDependency

 public override object FindDependency(Component comp, FieldInfo field)
 {
     if (SearchParents) {
         comp = comp.transform.root;
     }
     if (IsContainerType(field)) {
         Type type;
         if (field.FieldType.IsArray) {
             type = field.FieldType.GetElementType();
         } else if (typeof(IList).IsAssignableFrom(field.FieldType)) {
             if (field.FieldType.GetGenericArguments().Length >= 1) {
                 type = field.FieldType.GetGenericArguments()[0];
             } else {
                 Debug.LogError(string.Format("{0} expected at least one generic argument from the type {1}, use List<T>", this, field.FieldType));
                 return null;
             }
         } else {
             Debug.LogError("Shouldn't be here");
             type = null;
         }
         if (Recursive) {
             return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponentsInChildren(type, IncludeInactive)));
         }
         return CreateArrayOrList(field, ConvertToGOArray(comp.GetComponents(type)));
     }
     if (Recursive) {
         return comp.GetComponentInChildren(field.FieldType);
     }
     return comp.GetComponent(field.FieldType);
 }
開發者ID:paulmoore,項目名稱:UnJect,代碼行數:30,代碼來源:Attributes.cs


注:本文中的UnityEngine.Component.GetComponents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。