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


C# SerializedObject.Next方法代碼示例

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


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

示例1: GetReferencesOfAsset

	public static UnityObject[] GetReferencesOfAsset(UnityObject[] assets, bool prefabOnly = true) {
		if(assets == null || assets.Length == 0)
			return new GameObject[0];
		var result = new List<UnityObject>();
		var allObjects = UnityObject.FindObjectsOfType(typeof(UnityObject)) as UnityObject[];
		var allGameObjects = !prefabOnly ? GetChildrenWithInactive(allObjects) : new GameObject[0];
		foreach(var target in assets) {
			if(target == null)
				continue;
			if(prefabOnly) {
				foreach(var obj in allObjects)
					if(PrefabUtility.GetPrefabType(obj) == PrefabType.PrefabInstance && PrefabUtility.GetPrefabParent(obj) == target)
						result.Add(obj);
				continue;
			}
			foreach(var gameObject in allGameObjects) {
				var added = false;
				if(result.Contains(gameObject))
					continue;
				if(PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance && PrefabUtility.GetPrefabParent(gameObject) == target)
					result.Add(gameObject);
				foreach(var component in gameObject.GetComponents<Component>()) {
					if(target == component) {
						result.Add(gameObject);
						break;
					}
					var property = new SerializedObject(component).GetIterator();
					while(property != null && property.Next(true))
						if(property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue == target) {
							result.Add(gameObject);
							added = true;
							break;
						}
					if(added)
						break;
				}
			}
		}
		return result.ToArray();
	}
開發者ID:Teino1978-Corp,項目名稱:Teino1978-Corp-SelectReferencesUtils.cs,代碼行數:40,代碼來源:SelectReferencesUtils.cs

示例2: AddComponent

        /// <summary>
        /// Adds the copy of a Component to a GameObject.
        /// </summary>
        /// <param name="go">The GameObject that will get the new Component</param>
        /// <param name="original">The original component to copy</param>
        /// <returns>The reference to the newly added Component copy</returns>
        public static Component AddComponent(this GameObject go, Component original)
        {
            var c = go.AddComponent(original.GetType());

            var originalSerialized = new SerializedObject(original).GetIterator();
            var nso = new SerializedObject(c);
            var newSerialized = nso.GetIterator();

            if(originalSerialized.Next(true))
            {
                newSerialized.Next(true);

                while(originalSerialized.NextVisible(true))
                {
                    newSerialized.NextVisible(true);
                    newSerialized.SetValue(originalSerialized.GetValue());
                }
            }

            nso.ApplyModifiedProperties();

            return c;
        }
開發者ID:oskar-szulc,項目名稱:GitMerge-for-Unity,代碼行數:29,代碼來源:GameObjectExtensions.cs


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