Esempio n. 1
0
        /// <summary>
        /// This method loads all Presets in each of the given folder paths
        /// and updates the CustomDependency hash based on the Presets currently in that folder.
        /// </summary>
        static void DelayedDependencyRegistration(HashSet <string> folders)
        {
            foreach (var folder in folders)
            {
                var presetPaths =
                    AssetDatabase.FindAssets("glob:\"**.preset\"", new[] { folder })
                    .Select(AssetDatabase.GUIDToAssetPath)
                    .Where(presetPath => Path.GetDirectoryName(presetPath) == folder)
                    .OrderBy(a => a);

                Hash128 hash = new Hash128();
                foreach (var presetPath in presetPaths)
                {
                    // Append both path and Preset type to make sure assets get re-imported whenever a Preset type is changed.
                    hash.Append(presetPath);
                    hash.Append(AssetDatabase.LoadAssetAtPath <Preset>(presetPath).GetTargetFullTypeName());
                }

                AssetDatabase.RegisterCustomDependency($"PresetPostProcessor_{folder}", hash);
            }

            // Manually trigger a Refresh
            // so that the AssetDatabase triggers a dependency check on the updated folder hash.
            AssetDatabase.Refresh();
        }
Esempio n. 2
0
        internal static Hash128 CreateWindowAndStageIdentifier(string windowGUID, Stage stage)
        {
            Hash128 hash = stage.GetHashForStateStorage();

            hash.Append(windowGUID);
            hash.Append(stage.GetType().FullName);
            return(hash);
        }
Esempio n. 3
0
        public override int GetHashCode()
        {
            var h = new Hash128();

            unsafe
            {
                fixed(Hash128 *ptr = &m_SceneObjectsHash) h.Append(ptr, (ulong)sizeof(Hash128));

                fixed(Hash128 *ptr = &m_SkySettingsHash) h.Append(ptr, (ulong)sizeof(Hash128));

                fixed(Hash128 *ptr = &m_AmbientProbeHash) h.Append(ptr, (ulong)sizeof(Hash128));
            }
            return(h.GetHashCode());
        }
        void ImportXml(string xmlPath, out VisualTreeAsset vta)
        {
            var h = new Hash128();

            using (var stream = File.OpenRead(xmlPath))
            {
                int    readCount = 0;
                byte[] b         = new byte[1024 * 16];
                while ((readCount = stream.Read(b, 0, b.Length)) > 0)
                {
                    for (int i = readCount; i < b.Length; i++)
                    {
                        b[i] = 0;
                    }
                    h.Append(b);
                }
            }

            CreateVisualTreeAsset(out vta, h);

            XDocument doc;

            try
            {
                doc = XDocument.Load(xmlPath, LoadOptions.SetLineInfo);
            }
            catch (Exception e)
            {
                logger.LogError(ImportErrorType.Syntax, ImportErrorCode.InvalidXml, e, Error.Level.Fatal, null);
                return;
            }

            LoadXmlRoot(doc, vta);
            TryCreateInlineStyleSheet(vta);
        }
Esempio n. 5
0
        protected override void HashCore(byte[] inputBuffer, int inputOffset, int inputCount)
        {
            if (inputBuffer == null || inputOffset < 0 || inputCount <= 0 || (inputCount > inputBuffer.Length) || (inputBuffer.Length - inputCount) < inputOffset)
            {
                return;
            }

#if UNITY_2020_1_OR_NEWER
            m_Hash.Append(inputBuffer, inputOffset, inputCount);
#else
            throw new System.InvalidOperationException("SpookyHash implementation was unstable and not deterministic prior to Unity 2020.1. Use MD5 or MD4 instead.");
#endif
        }
Esempio n. 6
0
            public void Append(float[] values, int count)
            {
                if (values == null)
                {
                    return;
                }

                // Pre-2020 versions of Unity don't have Hash128.Append() (can only hash strings and scalars)
                // For these versions, we'll hash element by element.
#if UNITY_2020_1_OR_NEWER
                m_Hash.Append(values, 0, count);
#else
                for (var i = 0; i < count; i++)
                {
                    var tempHash = new Hash128();
                    HashUtilities.ComputeHash128(ref values[i], ref tempHash);
                    HashUtilities.AppendHash(ref tempHash, ref m_Hash);
                }
#endif
            }
Esempio n. 7
0
        internal static Hash128 GenerateHash(string uxmlPath)
        {
            var h = new Hash128();

            using (var stream = File.OpenRead(uxmlPath))
            {
                int    readCount = 0;
                byte[] b         = new byte[1024 * 16];
                while ((readCount = stream.Read(b, 0, b.Length)) > 0)
                {
                    for (int i = readCount; i < b.Length; i++)
                    {
                        b[i] = 0;
                    }
                    h.Append(b);
                }
            }

            return(h);
        }
 /// <summary>
 /// Sets the asset key for creating or retrieving state components.
 /// </summary>
 /// <param name="key">The unique asset key (for example, its GUID).</param>
 public void SetAssetKey(string key)
 {
     m_AssetViewHashBase = new Hash128();
     m_AssetViewHashBase.Append(key);
 }