コード例 #1
0
        private void InnerSaveAndReloadTest(string suffixname, Action <VisualEffectAsset> write, Action <VisualEffectAsset> read)
        {
            var kTempAssetPathA = string.Format("{0}/Temp_{1}_A.vfx", kTestAssetDir, suffixname);
            var kTempAssetPathB = string.Format("{0}/Temp_{1}_B.vfx", kTestAssetDir, suffixname);

            AssetDatabase.DeleteAsset(kTempAssetPathA);
            AssetDatabase.DeleteAsset(kTempAssetPathB);

            int hashCodeAsset = 0; //check reference are different between load & reload

            {
                var asset = CreateAssetAtPath(kTempAssetPathA);

                hashCodeAsset = asset.GetHashCode();

                write(asset);
                asset.GetResource().UpdateSubAssets();

                AssetDatabase.SaveAssets();

                asset = null;
                EditorUtility.UnloadUnusedAssetsImmediate();
                //AssetDatabase.CopyAsset(kTempAssetPathA, kTempAssetPathB); // TODO Deactivated because a regression makes it fail when load the copy
                File.Copy(kTempAssetPathA, kTempAssetPathB);

                if (asset != null)
                {
                    AssetDatabase.RemoveObjectFromAsset(asset);
                }
            }
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            EditorUtility.UnloadUnusedAssetsImmediate();
            {
                VisualEffectAsset asset = AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(kTempAssetPathB);
                Assert.AreNotEqual(hashCodeAsset, asset.GetHashCode());

                read(asset);
            }
            AssetDatabase.DeleteAsset(kTempAssetPathA);
            AssetDatabase.DeleteAsset(kTempAssetPathB);
        }
コード例 #2
0
        public override int GetHashCode()
        {
            int hash = base.GetHashCode();

            hash = ReferenceEquals(muzzleEffect, null) ? hash :  hash * 23 + muzzleEffect.GetHashCode();
            hash = ReferenceEquals(hitscanEffect, null) ? hash :  hash * 23 + hitscanEffect.GetHashCode();
            hash = ReferenceEquals(impactEffectEnvironment, null) ? hash :  hash * 23 + impactEffectEnvironment.GetHashCode();
            hash = ReferenceEquals(impactEffectCharacter, null) ? hash :  hash * 23 + impactEffectCharacter.GetHashCode();
            return(hash);
        }
コード例 #3
0
 public override int GetHashCode()
 {
     return(effect != null?effect.GetHashCode() : 0);
 }