public ReturnCode Run()
        {
            var setting = settingContext.Setting;

            if (setting == null)
            {
                return(ReturnCode.SuccessNotRun);
            }

            var objects = new HashSet <ObjectIdentifier>();

            foreach (var kv in dependencyData.AssetInfo)
            {
                var guid = kv.Key;
                var info = kv.Value;
                UnityEngine.Debug.Log($"{guid}");
                var path = AssetDatabase.GUIDToAssetPath(guid.ToString());
                if (!string.IsNullOrEmpty(path))
                {
                    var type = AssetDatabase.GetMainAssetTypeAtPath(path);
                    if (IsTargetAsset(path, type))
                    {
                        foreach (var obj in info.includedObjects)
                        {
                            objects.Add(obj);
                        }
                        foreach (var obj in info.referencedObjects)
                        {
                            objects.Add(obj);
                        }
                    }
                }
            }

            if (layout == null)
            {
                layout = new BundleExplictObjectLayout();
            }

            foreach (var obj in objects)
            {
                layout.ExplicitObjectLocation.Add(obj, BUNDLE_NAME);
            }


            if (layout.ExplicitObjectLocation.Count == 0)
            {
                layout = null;
            }

            return(ReturnCode.Success);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public ReturnCode Run()
        {
            HashSet <ObjectIdentifier> buildInObjects = new HashSet <ObjectIdentifier>();

            foreach (AssetLoadInfo dependencyInfo in m_DependencyData.AssetInfo.Values)
            {
                buildInObjects.UnionWith(dependencyInfo.referencedObjects.Where(x => x.guid == k_BuiltInGuid));
            }

            foreach (SceneDependencyInfo dependencyInfo in m_DependencyData.SceneInfo.Values)
            {
                buildInObjects.UnionWith(dependencyInfo.referencedObjects.Where(x => x.guid == k_BuiltInGuid));
            }

            ObjectIdentifier[] usedSet   = buildInObjects.ToArray();
            Type[]             usedTypes = BuildCacheUtility.GetMainTypeForObjects(usedSet);

            if (m_Layout == null)
            {
                m_Layout = new BundleExplictObjectLayout();
            }

            Type shader = typeof(Shader);

            for (int i = 0; i < usedTypes.Length; i++)
            {
                if (usedTypes[i] != shader)
                {
                    continue;
                }

                m_Layout.ExplicitObjectLocation.Add(usedSet[i], ShaderBundleName);
            }

            if (m_Layout.ExplicitObjectLocation.Count == 0)
            {
                m_Layout = null;
            }

            return(ReturnCode.Success);
        }