Exemplo n.º 1
0
        private List <CloneExclusion> GetExclusionsForObject(AssetsObject o, AssetsFile targetAssetsFile)
        {
            List <CloneExclusion> exclusions = new List <CloneExclusion>();

            //exclude any monobehaviors that the script type can't be found for
            exclusions.Add(new CloneExclusion(ExclusionMode.Remove)
            {
                Filter = (ptr, propInfo) =>
                {
                    var res = ptr != null && ptr.Object is MonoBehaviourObject && targetAssetsFile.Manager.GetScriptObject(ptr.Target.Type.TypeHash) == null;
                    if (res)
                    {
                        Log.LogMsg($"Removing MonoBehaviour object during cloning because type hash '{ptr.Target.Type.TypeHash}' doesn't exist in the target.");
                    }
                    return(res);
                }
            });
            exclusions.Add(new CloneExclusion(ExclusionMode.Remove)
            {
                Filter = (ptr, propInfo) =>
                {
                    var res = ptr != null && ptr.Target.Type.ClassID == AssetsConstants.ClassID.AnimationClassID;
                    if (res)
                    {
                        Log.LogMsg($"Removing Animation object during cloning because it isn't supported yet.");
                    }
                    return(res);
                }
            });
            if (typeof(Transform).IsAssignableFrom(o.GetType()))
            {
                exclusions.Add(new CloneExclusion(ExclusionMode.LeaveRef, propertyName: "Father", pointerTarget: ((Transform)o).Father.Target.Object));
            }
            return(exclusions);
        }
Exemplo n.º 2
0
        public static ISmartPtr <AssetsObject> MakeTypedPointer(AssetsObject owner, AssetsObject target)
        {
            var genericInfoType = typeof(SmartPtr <>).MakeGenericType(target.GetType());
            var constructor     = genericInfoType.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(AssetsObject), target.GetType() }, null);

            if (constructor == null)
            {
                throw new Exception("Unable to find the proper SmartPtr constructor!");
            }
            return((ISmartPtr <AssetsObject>)constructor.Invoke(new object[] { owner, target }));
        }