Пример #1
0
    public bool LoadDecalGroups(DecalView decalView)
    {
        decalGroups.Clear();

        if (s_decals == null)
        {
            return(false);
        }

        Dictionary <int, List <Decal> > dict = new Dictionary <int, List <Decal> >();

        foreach (string str in s_decals)
        {
            Decal d;
            if (Decal.Deserialize(str, out d))
            {
                int grpIndex = decalView == DecalView.Organizational ? d.orgGroup : d.atlasGroup;

                if (dict.ContainsKey(grpIndex))
                {
                    dict[grpIndex].Add(d);
                }
                else
                {
                    dict.Add(grpIndex, new List <Decal>()
                    {
                        d
                    });
                }
            }
        }

        foreach (KeyValuePair <int, List <Decal> > kvp in dict)
        {
            int      ag  = kvp.Value[0].atlasGroup;
            Material mat = (Material)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(materials[ag]), typeof(Material));
            decalGroups.Add(new DecalGroup(names[ag], kvp.Value, isPacked[ag], Shader.Find(shaders[ag]), mat, atlasSize[ag], padding[ag]));
        }

        // now sort the decals per index
        for (int i = 0; i < decalGroups.Count; i++)
        {
            qdUtil.SortDecalsUsingView(ref decalGroups[i].decals, decalView);
        }

        return(true);
    }