CopySerialized() приватный Метод

private CopySerialized ( Object source, Object dest ) : void
source Object
dest Object
Результат void
Пример #1
0
        public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
        {
            Auto_Tile_Base myTile = target as Auto_Tile_Base;

            if (myTile == null)
            {
                return(null);
            }

            var preview = AssetPreview.GetAssetPreview(myTile.preview);

            if (preview == null)
            {
                return(null);
            }

            Texture2D cache = new Texture2D(width, height);

            EditorUtility.CopySerialized(preview, cache);

            return(cache);
        }
Пример #2
0
        internal static void DuplicateSelectedAssets()
        {
            AssetDatabase.Refresh();
            UnityEngine.Object[] objects = Selection.objects;
            bool flag = true;

            UnityEngine.Object[] array = objects;
            for (int i = 0; i < array.Length; i++)
            {
                UnityEngine.Object @object       = array[i];
                AnimationClip      animationClip = @object as AnimationClip;
                if (animationClip == null || (animationClip.hideFlags & HideFlags.NotEditable) == HideFlags.None || !AssetDatabase.Contains(animationClip))
                {
                    flag = false;
                }
            }
            ArrayList arrayList = new ArrayList();
            bool      flag2     = false;

            if (flag)
            {
                UnityEngine.Object[] array2 = objects;
                for (int j = 0; j < array2.Length; j++)
                {
                    UnityEngine.Object object2        = array2[j];
                    AnimationClip      animationClip2 = object2 as AnimationClip;
                    if (animationClip2 != null && (animationClip2.hideFlags & HideFlags.NotEditable) != HideFlags.None)
                    {
                        string path = AssetDatabase.GetAssetPath(object2);
                        path = Path.Combine(Path.GetDirectoryName(path), animationClip2.name) + ".anim";
                        string        text           = AssetDatabase.GenerateUniqueAssetPath(path);
                        AnimationClip animationClip3 = new AnimationClip();
                        EditorUtility.CopySerialized(animationClip2, animationClip3);
                        AssetDatabase.CreateAsset(animationClip3, text);
                        arrayList.Add(text);
                    }
                }
            }
            else
            {
                UnityEngine.Object[] filtered = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets);
                UnityEngine.Object[] array3   = filtered;
                for (int k = 0; k < array3.Length; k++)
                {
                    UnityEngine.Object assetObject = array3[k];
                    string             assetPath   = AssetDatabase.GetAssetPath(assetObject);
                    string             text2       = AssetDatabase.GenerateUniqueAssetPath(assetPath);
                    if (text2.Length != 0)
                    {
                        flag2 |= !AssetDatabase.CopyAsset(assetPath, text2);
                    }
                    else
                    {
                        flag2 |= true;
                    }
                    if (!flag2)
                    {
                        arrayList.Add(text2);
                    }
                }
            }
            AssetDatabase.Refresh();
            UnityEngine.Object[] array4 = new UnityEngine.Object[arrayList.Count];
            for (int l = 0; l < arrayList.Count; l++)
            {
                array4[l] = AssetDatabase.LoadMainAssetAtPath(arrayList[l] as string);
            }
            Selection.objects = array4;
        }
Пример #3
0
        internal static void DuplicateSelectedAssets()
        {
            AssetDatabase.Refresh();
            UnityEngine.Object[] objects = Selection.objects;
            bool flag = true;

            foreach (UnityEngine.Object obj2 in objects)
            {
                AnimationClip clip = obj2 as AnimationClip;
                if (((clip == null) || ((clip.hideFlags & HideFlags.NotEditable) == HideFlags.None)) || !AssetDatabase.Contains(clip))
                {
                    flag = false;
                }
            }
            ArrayList list  = new ArrayList();
            bool      flag2 = false;

            if (flag)
            {
                foreach (UnityEngine.Object obj3 in objects)
                {
                    AnimationClip source = obj3 as AnimationClip;
                    if ((source != null) && ((source.hideFlags & HideFlags.NotEditable) != HideFlags.None))
                    {
                        string        path = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(Path.GetDirectoryName(AssetDatabase.GetAssetPath(obj3)), source.name) + ".anim");
                        AnimationClip dest = new AnimationClip();
                        EditorUtility.CopySerialized(source, dest);
                        AssetDatabase.CreateAsset(dest, path);
                        list.Add(path);
                    }
                }
            }
            else
            {
                UnityEngine.Object[] filtered = Selection.GetFiltered(typeof(UnityEngine.Object), UnityEditor.SelectionMode.Assets);
                foreach (UnityEngine.Object obj4 in filtered)
                {
                    string assetPath = AssetDatabase.GetAssetPath(obj4);
                    string newPath   = AssetDatabase.GenerateUniqueAssetPath(assetPath);
                    if (newPath.Length != 0)
                    {
                        flag2 |= !AssetDatabase.CopyAsset(assetPath, newPath);
                    }
                    else
                    {
                        flag2 |= true;
                    }
                    if (!flag2)
                    {
                        list.Add(newPath);
                    }
                }
            }
            AssetDatabase.Refresh();
            UnityEngine.Object[] objArray6 = new UnityEngine.Object[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                objArray6[i] = AssetDatabase.LoadMainAssetAtPath(list[i] as string);
            }
            Selection.objects = objArray6;
        }