void SyncListSelectionToValue(TemplateInstantiationMode mode)
 {
     if (listView.selectedIndex != -1)
     {
         var listContent = listView.Q <VisualElement>("unity-content-container");
         foreach (var row in listContent.Children())
         {
             if (row.ClassListContains("unity-list-view__item--selected"))
             {
                 SetDependencyInstantiationMode(row, mode);
             }
         }
     }
     m_SerializedObject.ApplyModifiedProperties();
 }
Beispiel #2
0
        private void SetDependencyInstantiationMode(VisualElement row, TemplateInstantiationMode mode)
        {
            var prop   = (SerializedProperty)row.userData;
            var toggle = (Toggle)row.ElementAt(2);

            if (!toggle.enabledSelf)
            {
                return;
            }

            toggle.SetValueWithoutNotify(mode == TemplateInstantiationMode.Clone);

            var depProp = prop.FindPropertyRelative(k_InstantiationModePropertyName);

            if (depProp.enumValueIndex != (int)mode)
            {
                depProp.enumValueIndex = (int)mode;
            }
        }
        static void SetDependencyInstantiationMode(VisualElement row, TemplateInstantiationMode mode)
        {
            var prop    = (SerializedProperty)row.userData;
            var rowItem = (DependencyRowItem)row;
            var toggle  = rowItem.cloneToggle;

            if (!toggle.enabledSelf)
            {
                return;
            }

            toggle.SetValueWithoutNotify(mode == TemplateInstantiationMode.Clone);

            var depProp = prop.FindPropertyRelative(SceneTemplateUtils.InstantiationModePropertyName);

            if (depProp.enumValueIndex != (int)mode)
            {
                depProp.enumValueIndex = (int)mode;
            }
        }