当前位置: 首页>>代码示例>>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;未经允许,请勿转载。