当前位置: 首页>>代码示例>>C#>>正文


C# SerializedProperty.Copy方法代码示例

本文整理汇总了C#中UnityEditor.SerializedProperty.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty.Copy方法的具体用法?C# SerializedProperty.Copy怎么用?C# SerializedProperty.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEditor.SerializedProperty的用法示例。


在下文中一共展示了SerializedProperty.Copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyPropertyValue

		public static void CopyPropertyValue(SerializedProperty source, SerializedProperty dest)
		{
			source = source.Copy();
			dest = dest.Copy();

			var destSO = dest.serializedObject;


			if (source.hasVisibleChildren)
			{
				var sourceRoot = source.propertyPath;
				var destRoot = dest.propertyPath;

				while (source.NextVisible(true) && source.propertyPath.StartsWith(sourceRoot))
				{
					if (source.propertyType == SerializedPropertyType.Generic)
						continue;

					var path = destRoot + source.propertyPath.Remove(0, sourceRoot.Length);
					var destProperty = destSO.FindProperty(path);
					SetPropertyValue(destProperty, GetPropertyValue(source));
				}
			}
			else
			{
				if (dest.propertyPath == "m_RootOrder")
				{
					(dest.serializedObject.targetObject as Transform).SetSiblingIndex((int)GetPropertyValue(source));
				}
				SetPropertyValue(dest, GetPropertyValue(source));
			}
		}
开发者ID:Zammy,项目名称:ProjectSpaceship,代码行数:32,代码来源:PEPropertyHelper.cs

示例2: GetHeight

        public float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (_visibleDrawer == null) this.Init();

            property = property.Copy();
            if (label == null) label = EditorHelper.TempContent(property.displayName);

            if (_visibleDrawer is IArrayHandlingPropertyDrawer || !property.isArray)
            {
                return _visibleDrawer.GetPropertyHeight(property, label);
            }
            else
            {
                float h = SPEditorGUI.GetSinglePropertyHeight(property, label);
                if (!includeChildren || !property.isExpanded) return h;

                h += EditorGUIUtility.singleLineHeight + 2f;

                for(int i = 0; i < property.arraySize; i++)
                {
                    var pchild = property.GetArrayElementAtIndex(i);
                    h += _visibleDrawer.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f;
                }
                return h;
            }
        }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:26,代码来源:SPPropertyAttributePropertyHandler.cs

示例3: OnGUI

	public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
	{
		position.height = EditorGUIUtility.singleLineHeight;
		property = property.Copy();
		property.NextVisible(true);
		EditorGUI.PropertyField(position, property);
		position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
		property.NextVisible(true);
		EditorGUI.PropertyField(position, property);
	}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:10,代码来源:CustomClassPropertySetterExampleEditor.cs

示例4: GetChildrenCount

 internal static int GetChildrenCount(SerializedProperty property)
 {
     int num = 0;
     SerializedProperty x = property.Copy();
     SerializedProperty endProperty = x.GetEndProperty();
     while (!SerializedProperty.EqualContents(x, endProperty))
     {
         num++;
         x.NextVisible(true);
     }
     return num;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:12,代码来源:StructPropertyGUILayout.cs

示例5: ArrayProperty

 public static void ArrayProperty(string name, SerializedProperty prop) {
     SerializedProperty localProp = prop.Copy();
     tk2dGuiUtility.LookLikeInspector();
     if ( EditorGUILayout.PropertyField(localProp, new GUIContent(name)) ) {
         EditorGUI.indentLevel++;
         bool expanded = true;
         int depth = localProp.depth;
         while (localProp.NextVisible( expanded ) && depth < localProp.depth) {
             expanded = EditorGUILayout.PropertyField(localProp);
         }
         EditorGUI.indentLevel--;
     }
 }
开发者ID:gouki04,项目名称:Escape,代码行数:13,代码来源:tk2dUIItemEditor.cs

示例6: GetChildProperty

        /// <summary>
        /// 	Runs through all the child objects and return the one that matches the given name
        /// </summary>
        private static SerializedProperty GetChildProperty(SerializedProperty parent, string name)
        {
            SerializedProperty child = parent.Copy();
            child.Next(true);

            do
            {
                if (child.name == name) return child;
            }
            while (child.Next(false));

            return null;
        }
开发者ID:JISyed,项目名称:Unity-XboxCtrlrInput,代码行数:16,代码来源:InputManagerCloner.cs

示例7: GetChildrenCount

		internal static int GetChildrenCount(SerializedProperty property)
		{
			int depth = property.depth;
			SerializedProperty serializedProperty = property.Copy();
			serializedProperty.NextVisible(true);
			int num = 0;
			while (serializedProperty.depth == depth + 1)
			{
				num++;
				serializedProperty.NextVisible(false);
			}
			return num;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:13,代码来源:StructPropertyGUILayout.cs

示例8: ResetChildPropertyValues

		private static void ResetChildPropertyValues(SerializedProperty element) {
			if (!element.hasChildren)
				return;

			var childProperty = element.Copy();
			int elementPropertyDepth = element.depth;
			bool enterChildren = true;

			while (childProperty.Next(enterChildren) && childProperty.depth > elementPropertyDepth) {
				enterChildren = false;
				ResetValue(childProperty);
			}
		}
开发者ID:zorbathut,项目名称:gt_byg,代码行数:13,代码来源:SerializedPropertyUtility.cs

示例9: GetChildrenCount

 internal static int GetChildrenCount(SerializedProperty property)
 {
     int depth = property.depth;
     SerializedProperty property2 = property.Copy();
     property2.NextVisible(true);
     int num2 = 0;
     while (property2.depth == (depth + 1))
     {
         num2++;
         property2.NextVisible(false);
     }
     return num2;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:13,代码来源:StructPropertyGUILayout.cs

示例10: GetPropertyHeight

    /// <summary>
    /// Gets the height of the property.
    /// </summary>
    public override float GetPropertyHeight( SerializedProperty property, GUIContent label )
    {
        float h = 0.0f;

        if( !heightIsChanged )
        {
            return cacheHeight;
        }

        if( property.isArray )
        {
            // header.
            h += c_fieldHeight;

            if( property.isExpanded )
            {
                // size.
                {
                    SerializedProperty propCopy = property.Copy();
                    propCopy.Next( true );
                    h += EditorGUI.GetPropertyHeight( propCopy );
                }

                // elements.
                int size = property.arraySize;
                for( int i=0; i<size; ++i )
                {
                    SerializedProperty propElement = property.GetArrayElementAtIndex( i );
                    SerializedProperty propEnd     = propElement.GetEndProperty();

                    // elements internal.
                    do
                    { h += EditorGUI.GetPropertyHeight( propElement, label, false ); }
                    while( propElement.NextVisible( propElement.isExpanded ) &&
                            !SerializedProperty.EqualContents( propElement, propEnd ) );
                }
            }
        }
        else
        {	// helpbox.
            h += c_helpboxHeight;
        }

        cacheHeight = h;
        heightIsChanged = false;

        return h;
    }
开发者ID:KurataKazuaki,项目名称:Unity-SmartArrayPropertyDrawer,代码行数:51,代码来源:SmartArrayPropertyDrawer.cs

示例11: DoChildren

 private static void DoChildren(Rect position, SerializedProperty property)
 {
   float depth = (float) property.depth;
   position.height = 16f;
   ++EditorGUI.indentLevel;
   SerializedProperty property1 = property.Copy();
   property1.NextVisible(true);
   while ((double) property1.depth == (double) depth + 1.0)
   {
     EditorGUI.PropertyField(position, property1);
     position.y += 16f;
     property1.NextVisible(false);
   }
   --EditorGUI.indentLevel;
   EditorGUILayout.Space();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:16,代码来源:StructPropertyGUI.cs

示例12: DoChildren

 private static void DoChildren(Rect position, SerializedProperty property)
 {
     float depth = property.depth;
     position.height = 16f;
     EditorGUI.indentLevel++;
     SerializedProperty property2 = property.Copy();
     property2.NextVisible(true);
     while (property2.depth == (depth + 1f))
     {
         EditorGUI.PropertyField(position, property2);
         position.y += 16f;
         property2.NextVisible(false);
     }
     EditorGUI.indentLevel--;
     EditorGUILayout.Space();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:16,代码来源:StructPropertyGUI.cs

示例13: DoChildren

		private static void DoChildren(Rect position, SerializedProperty property)
		{
			float num = (float)property.depth;
			position.height = 16f;
			EditorGUI.indentLevel++;
			SerializedProperty serializedProperty = property.Copy();
			serializedProperty.NextVisible(true);
			while ((float)serializedProperty.depth == num + 1f)
			{
				EditorGUI.PropertyField(position, serializedProperty);
				position.y += 16f;
				serializedProperty.NextVisible(false);
			}
			EditorGUI.indentLevel--;
			EditorGUILayout.Space();
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:16,代码来源:StructPropertyGUI.cs

示例14: OnGUI

        public bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (_visibleDrawer == null) this.Init();

            property = property.Copy();
            if (label == null) label = EditorHelper.TempContent(property.displayName);

            if (_visibleDrawer is IArrayHandlingPropertyDrawer || !property.isArray)
            {
                _visibleDrawer.OnGUI(position, property, label);
                PropertyHandlerValidationUtility.AddAsHandled(property, this);
                return !includeChildren && property.isExpanded;
            }
            else
            {
                if (includeChildren && property.isExpanded)
                {
                    var rect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);
                    property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, label);

                    EditorGUI.indentLevel++;
                    rect = new Rect(rect.xMin, rect.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight);
                    property.arraySize = Mathf.Max(0, EditorGUI.IntField(rect, "Size", property.arraySize));

                    var lbl = EditorHelper.TempContent("");
                    for (int i = 0; i < property.arraySize; i++)
                    {
                        var pchild = property.GetArrayElementAtIndex(i);
                        lbl.text = pchild.displayName;
                        var h = _visibleDrawer.GetPropertyHeight(pchild, lbl);
                        rect = new Rect(rect.xMin, rect.yMax + 2f, rect.width, h);
                        _visibleDrawer.OnGUI(rect, pchild, lbl);
                    }

                    EditorGUI.indentLevel--;
                    PropertyHandlerValidationUtility.AddAsHandled(property, this);
                    return true;
                }
                else
                {
                    property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label);
                    PropertyHandlerValidationUtility.AddAsHandled(property, this);
                    return false;
                }
            }
        }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:46,代码来源:SPPropertyAttributePropertyHandler.cs

示例15: DrawArrayProperty

    private void DrawArrayProperty(SerializedProperty prop)
    {
        EditorGUILayout.PropertyField(prop);
        if (prop.isExpanded)
        {
            EditorGUI.indentLevel++;
            SerializedProperty propChild = prop.Copy();
            propChild.NextVisible(true);
            EditorGUILayout.PropertyField(propChild);
            bool arrayDiff = true;
            SerializedProperty preProp = null;
            if (prop.isInstantiatedPrefab)
                preProp = new SerializedObject(PrefabUtility.GetPrefabParent(prop.serializedObject.targetObject)).FindProperty(prop.name);
            for (int i = 0; i < prop.arraySize; i++)
            {
                SerializedProperty item = prop.GetArrayElementAtIndex(i);
                if (item.isArray)
                {
                    DrawArrayProperty(item);
                }
                else
                {
                    EditorGUILayout.PropertyField(item);
                    if (prop.isInstantiatedPrefab)
                    {
                        if (preProp != null && preProp.arraySize == prop.arraySize && PropEquals(item, preProp.GetArrayElementAtIndex(i)))
                        {
                            item.prefabOverride = false;

                        } else
                        {
                            arrayDiff = false;
                        }

                    }
                }

            }
            if(arrayDiff)
            {
                prop.prefabOverride = false;
            }
            EditorGUI.indentLevel--;
        }
    }
开发者ID:Ryxali,项目名称:GameTweaker,代码行数:45,代码来源:GameTweaker.cs


注:本文中的UnityEditor.SerializedProperty.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。