Exemplo n.º 1
0
        public void Restore(object str)
        {
            Profiler.BeginSample("VFXGraph.Restore");
            var scriptableObject = VFXMemorySerializer.ExtractObjects(str as byte[], false);

            Profiler.BeginSample("VFXGraph.Restore SendUnknownChange");
            foreach (var model in scriptableObject.OfType <VFXModel>())
            {
                model.OnUnknownChange();
            }
            Profiler.EndSample();
            Profiler.EndSample();
            m_SystemNames.Sync(this);
            m_ExpressionGraphDirty  = true;
            m_ExpressionValuesDirty = true;
            m_DependentDirty        = true;
        }
Exemplo n.º 2
0
        public void SanitizeGraph()
        {
            if (m_GraphSanitized)
            {
                return;
            }

            var objs = new HashSet <ScriptableObject>();

            CollectDependencies(objs);

            foreach (var model in objs.OfType <VFXModel>())
            {
                try
                {
                    model.Sanitize(m_GraphVersion); // This can modify dependencies but newly created model are supposed safe so we dont care about retrieving new dependencies
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing model: {0} of type {1}: {2} {3}", model.name, model.GetType(), e, e.StackTrace));
                }
            }

            if (m_UIInfos != null)
            {
                try
                {
                    m_UIInfos.Sanitize(this);
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing VFXUI: : {0} {1}", e, e.StackTrace));
                }
            }

            systemNames.Sync(this);

            m_GraphSanitized = true;
            m_GraphVersion   = CurrentVersion;
            UpdateSubAssets(); //Should not be necessary : force remove no more referenced object from asset
        }
Exemplo n.º 3
0
        public void SanitizeGraph()
        {
            if (m_GraphSanitized)
            {
                return;
            }

            var objs = new HashSet <ScriptableObject>();

            CollectDependencies(objs);

            if (version < 7)
            {
                SanitizeCameraBuffers(objs);
            }

            foreach (var model in objs.OfType <VFXModel>())
            {
                try
                {
                    model.Sanitize(m_GraphVersion); // This can modify dependencies but newly created model are supposed safe so we dont care about retrieving new dependencies
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing model: {0} of type {1}: {2} {3}", model.name, model.GetType(), e, e.StackTrace));
                }
            }

            if (m_UIInfos != null)
            {
                try
                {
                    m_UIInfos.Sanitize(this);
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing VFXUI: : {0} {1}", e, e.StackTrace));
                }
            }

            systemNames.Sync(this);


            int resourceCurrentVersion = 0;
            // Stop using reflection after 2020.2;
            FieldInfo info = typeof(VisualEffectResource).GetField("CurrentVersion", BindingFlags.Static | System.Reflection.BindingFlags.Public);

            if (info != null)
            {
                resourceCurrentVersion = (int)info.GetValue(null);
            }

            if (m_ResourceVersion < resourceCurrentVersion) // Graph not up to date
            {
                if (m_ResourceVersion < 1)                  // Version before gradient interpreted as linear
                {
                    foreach (var model in objs.OfType <VFXSlotGradient>())
                    {
                        Gradient           value = (Gradient)model.value;
                        GradientColorKey[] keys  = value.colorKeys;

                        for (int i = 0; i < keys.Length; ++i)
                        {
                            var colorKey = keys[i];
                            colorKey.color = colorKey.color.linear;
                            keys[i]        = colorKey;
                        }
                        value.colorKeys = keys;
                        model.value     = new Gradient();
                        model.value     = value;
                    }
                }
            }
            m_ResourceVersion = resourceCurrentVersion;
            m_GraphSanitized  = true;
            m_GraphVersion    = CurrentVersion;

#if !CASE_1289829_HAS_BEEN_FIXED
            if (visualEffectResource != null && (visualEffectResource.updateMode & VFXUpdateMode.ExactFixedTimeStep) == VFXUpdateMode.ExactFixedTimeStep)
            {
                visualEffectResource.updateMode = visualEffectResource.updateMode & ~VFXUpdateMode.ExactFixedTimeStep;
                Debug.Log("Sanitize : Exact Fixed Time has been automatically reset to false to avoid an unexpected behavior.");
            }
#endif

            UpdateSubAssets(); //Should not be necessary : force remove no more referenced object from asset
        }
Exemplo n.º 4
0
        public void SanitizeGraph()
        {
            if (m_GraphSanitized)
            {
                return;
            }

            var objs = new HashSet <ScriptableObject>();

            CollectDependencies(objs);

            if (version < 7)
            {
                SanitizeCameraBuffers(objs);
            }

            foreach (var model in objs.OfType <VFXModel>())
            {
                try
                {
                    model.Sanitize(m_GraphVersion); // This can modify dependencies but newly created model are supposed safe so we dont care about retrieving new dependencies
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing model: {0} of type {1}: {2} {3}", model.name, model.GetType(), e, e.StackTrace));
                }
            }

            if (m_UIInfos != null)
            {
                try
                {
                    m_UIInfos.Sanitize(this);
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("Exception while sanitizing VFXUI: : {0} {1}", e, e.StackTrace));
                }
            }

            systemNames.Sync(this);


            int resourceCurrentVersion = 0;
            // Stop using reflection after 2020.2;
            FieldInfo info = typeof(VisualEffectResource).GetField("CurrentVersion", BindingFlags.Static | System.Reflection.BindingFlags.Public);

            if (info != null)
            {
                resourceCurrentVersion = (int)info.GetValue(null);
            }

            if (m_ResourceVersion < resourceCurrentVersion) // Graph not up to date
            {
                if (m_ResourceVersion < 1)                  // Version before gradient interpreted as linear
                {
                    foreach (var model in objs.OfType <VFXSlotGradient>())
                    {
                        Gradient           value = (Gradient)model.value;
                        GradientColorKey[] keys  = value.colorKeys;

                        for (int i = 0; i < keys.Length; ++i)
                        {
                            var colorKey = keys[i];
                            colorKey.color = colorKey.color.linear;
                            keys[i]        = colorKey;
                        }
                        value.colorKeys = keys;
                        model.value     = new Gradient();
                        model.value     = value;
                    }
                }
            }
            m_ResourceVersion = resourceCurrentVersion;
            m_GraphSanitized  = true;
            m_GraphVersion    = CurrentVersion;

            UpdateSubAssets(); //Force remove no more referenced object from the asset & *important* register as persistent new dependencies
        }