Version: 2022.1
언어: 한국어

SerializedProperty.hasMultipleDifferentValues

매뉴얼로 전환
public bool hasMultipleDifferentValues ;

설명

Does this property represent multiple different values due to multi-object editing? (Read Only)

Returns true when there are multiple target objects, and they do not all have the same value. See Also: SerializedObject.targetObjects, SerializedObject.SetIsDifferentCacheDirty.

using UnityEngine;
using UnityEditor;

public class SerializePropertyHasMultipleDifferentValuesExample : ScriptableObject { public int m_Matching; public int m_Different;

[MenuItem("Example/SerializedProperty hasMultipleDifferentValues Example")] static void HasMultipleDifferentValuesExample() { var instance1 = ScriptableObject.CreateInstance<SerializePropertyHasMultipleDifferentValuesExample>(); instance1.m_Matching = 1; instance1.m_Different = 1;

var instance2 = ScriptableObject.CreateInstance<SerializePropertyHasMultipleDifferentValuesExample>(); instance2.m_Matching = 1; instance2.m_Different = 2;

using (var serializedObject = new SerializedObject(new ScriptableObject[] { instance1, instance2 })) { var matchingProperty = serializedObject.FindProperty("m_Matching"); var differentProperty = serializedObject.FindProperty("m_Different");

// Outputs //m_Matching value: 1, matching: True //m_Different value: 1, matching: False Debug.Log($"m_Matching value: {matchingProperty.intValue}, matching: {!matchingProperty.hasMultipleDifferentValues}\n" + $"m_Different value: {differentProperty.intValue}, matching: {!differentProperty.hasMultipleDifferentValues}"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961