Example #1
0
		internal static GameObject FindSelectionBase(GameObject go)
		{
			GameObject result;
			if (go == null)
			{
				result = null;
			}
			else
			{
				Transform y = null;
				PrefabType prefabType = PrefabUtility.GetPrefabType(go);
				if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.ModelPrefabInstance)
				{
					y = PrefabUtility.FindPrefabRoot(go).transform;
				}
				Transform transform = go.transform;
				while (transform != null)
				{
					if (transform == y)
					{
						result = transform.gameObject;
						return result;
					}
					if (AttributeHelper.GameObjectContainsAttribute(transform.gameObject, typeof(SelectionBaseAttribute)))
					{
						result = transform.gameObject;
						return result;
					}
					transform = transform.parent;
				}
				result = null;
			}
			return result;
		}
Example #2
0
 internal static GameObject FindSelectionBase(GameObject go)
 {
     if (go != null)
     {
         Transform transform = null;
         switch (PrefabUtility.GetPrefabType(go))
         {
         case PrefabType.PrefabInstance:
         case PrefabType.ModelPrefabInstance:
             transform = PrefabUtility.FindPrefabRoot(go).transform;
             break;
         }
         for (Transform transform2 = go.transform; transform2 != null; transform2 = transform2.parent)
         {
             if (transform2 == transform)
             {
                 return(transform2.gameObject);
             }
             if (AttributeHelper.GameObjectContainsAttribute(transform2.gameObject, typeof(SelectionBaseAttribute)))
             {
                 return(transform2.gameObject);
             }
         }
     }
     return(null);
 }
        internal static GameObject FindSelectionBase(GameObject go)
        {
            if (go == null)
            {
                return(null);
            }

            Transform  prefabBase = null;
            PrefabType pickedType = PrefabUtility.GetPrefabType(go);

            if (pickedType == PrefabType.PrefabInstance || pickedType == PrefabType.ModelPrefabInstance)
            {
                prefabBase = PrefabUtility.FindPrefabRoot(go).transform;
            }

            Transform tr = go.transform;

            while (tr != null)
            {
                if (tr == prefabBase)
                {
                    return(tr.gameObject);
                }

                if (AttributeHelper.GameObjectContainsAttribute <SelectionBaseAttribute>(tr.gameObject))
                {
                    return(tr.gameObject);
                }

                tr = tr.parent;
            }

            return(null);
        }
Example #4
0
        internal static GameObject FindSelectionBase(GameObject go)
        {
            if (go == null)
            {
                return(null);
            }

            // Find prefab based base
            Transform  prefabBase = null;
            PrefabType pickedType = PrefabUtility.GetPrefabType(go);

            if (pickedType == PrefabType.PrefabInstance || pickedType == PrefabType.ModelPrefabInstance)
            {
                prefabBase = PrefabUtility.FindPrefabRoot(go).transform;
            }

            // Find attribute based base
            Transform tr = go.transform;

            while (tr != null)
            {
                // If we come across the prefab base, no need to search further down.
                if (tr == prefabBase)
                {
                    return(tr.gameObject);
                }

                // If this one has the attribute, return this one.
                if (AttributeHelper.GameObjectContainsAttribute <SelectionBaseAttribute>(tr.gameObject))
                {
                    return(tr.gameObject);
                }

                tr = tr.parent;
            }

            // There is neither a prefab or attribute based selection root, so return null
            return(null);
        }