public static List <Object> CloneTrack(this PlayableDirector self, PlayableDirector dest, string trackName)
        {
            List <Object> toRemoveList        = new List <Object>();
            TimelineAsset sourceTimelineAsset = (TimelineAsset)self.playableAsset;
            TimelineAsset cloneTimelineAsset  = sourceTimelineAsset.CloneTrackAsset(trackName);

            dest.playableAsset = cloneTimelineAsset;
            toRemoveList.Add(cloneTimelineAsset);
            Object sourceBinding = self.GetGenericBinding(sourceTimelineAsset.GetTrackAsset(trackName));

            if (sourceBinding != null)
            {
                Object clone_binding;
                if (sourceBinding is Component c)
                {
                    GameObject cloneBindingGameObject = Object.Instantiate(c.gameObject);
                    cloneBindingGameObject.transform.CopyFrom(c.transform);
                    clone_binding = cloneBindingGameObject.GetComponent(c.GetType());
                    toRemoveList.Add(cloneBindingGameObject);
                }
                else
                {
                    clone_binding = Object.Instantiate(sourceBinding);
                    toRemoveList.Add(clone_binding);
                }

                clone_binding.name = StringUtilCat.RoundBrackets(StringConst.String_clone) + sourceBinding.name;
                dest.SetGenericBinding(cloneTimelineAsset.GetTrackAsset(trackName), clone_binding);
            }

            return(toRemoveList);
        }
Exemple #2
0
        public static Type GetType(string classPath, string dllName = null)
        {
            // return Type.GetType(string.Format("{0}, {1}, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", className, dllName));
            if (dllName == null && GetCacheDict().ContainsKey(classPath))
            {
                return(GetCacheDict()[classPath]);
            }

            string dllName1 = dllName;

            if (dllName == null)
            {
                dllName1 = Assembly.GetExecutingAssembly().FullName;
            }
            string typeString = StringUtilCat.LinkStringWithCommon(classPath, dllName1);

            if (GetCacheDict().ContainsKey(typeString))
            {
                return(GetCacheDict()[typeString]);
            }

            Type result = Type.GetType(typeString);

            if (dllName == null)             //查找所有assembly中的类
            {
                Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                for (var i = 0; i < assemblies.Length; i++)
                {
                    var assembly = assemblies[i];
                    result = assembly.GetType(classPath);
                    if (result == null)
                    {
                        continue;
                    }
                    GetCacheDict()[StringUtilCat.LinkStringWithCommon(classPath, assembly.FullName)] = result;
                    break;
                }
            }

            GetCacheDict()[StringUtilCat.LinkStringWithCommon(classPath, dllName ?? StringConst.String_Empty)] = result;
            return(result);
        }