Ejemplo n.º 1
0
        internal static bool AddNewType(Type type)
        {
            if (!CanAddType(type))
            {
                return(false);
            }

            var typeId     = type.FullName;
            var label      = DependencyTypeInfo.ToShortFullName(type.FullName);
            var settings   = Get();
            var newDepInfo = new DependencyTypeInfo(typeId, label)
            {
                defaultInstantiationMode = TemplateInstantiationMode.Clone,
                userAdded = true
            };

            var depInfoWidth = EditorStyles.label.CalcSize(newDepInfo.content).x;

            if (depInfoWidth > m_MaxLabelWidth)
            {
                m_MaxLabelWidth = Mathf.Min(kMaxLabelWidth, depInfoWidth);
            }

            settings.dependencyTypeInfos.Add(newDepInfo);
            Sort(settings.dependencyTypeInfos);
            Save();

            return(true);
        }
Ejemplo n.º 2
0
        void SetupDependencyTypeInfos()
        {
            var needSaving = false;

            if (defaultDependencyTypeInfo == null)
            {
                defaultDependencyTypeInfo = new DependencyTypeInfo("<default_scene_template_dependencies>")
                {
                    ignore = false,
                    defaultInstantiationMode = TemplateInstantiationMode.Reference,
                    supportsModification     = true
                };
                needSaving = true;
            }

            foreach (var dependencyTypeInfo in defaultDependencyTypeInfos)
            {
                if (dependencyTypeInfos.Find(dti => dti.type == dependencyTypeInfo.type) == null)
                {
                    var dti = new DependencyTypeInfo(dependencyTypeInfo);
                    dependencyTypeInfos.Add(dti);
                    needSaving = true;
                }
            }

            Sort(dependencyTypeInfos);

            if (needSaving)
            {
                Save(k_Path, this);
            }
        }
 public void AssignFrom(DependencyTypeInfo src)
 {
     userAdded = src.userAdded;
     type      = src.type;
     ignore    = src.ignore;
     defaultInstantiationMode = src.defaultInstantiationMode;
     supportsModification     = src.supportsModification;
 }
Ejemplo n.º 4
0
 static IEnumerable <SearchProposition> BuildPropositionsFromTypes(IEnumerable <Type> types)
 {
     foreach (var t in types)
     {
         yield return(new SearchProposition(
                          label: DependencyTypeInfo.ToShortFullName(t.FullName),
                          type: t,
                          icon: Search.SearchUtils.GetTypeIcon(t)));
     }
 }
 private static SettingsProvider CreateSettings()
 {
     return(new SettingsProvider(k_SettingsKey, SettingsScope.Project)
     {
         keywords = new[] { "unity", "editor", "scene", "clone", "template" },
         activateHandler = (text, rootElement) =>
         {
             if (m_AllTypes == null)
             {
                 m_AllTypes = TypeCache.GetTypesDerivedFrom <UnityEngine.Object>().ToArray();
                 m_AllTypesLabels = m_AllTypes.Select(t => DependencyTypeInfo.ToShortFullName(t.FullName)).ToArray();
             }
             m_TypeToAddLabel = "";
             m_TypeToAdd = null;
         },
         label = "Scene Template",
         guiHandler = OnGUIHandler
     });
 }
Ejemplo n.º 6
0
 public DependencyTypeInfo(DependencyTypeInfo src)
 {
     AssignFrom(src);
 }