Esempio n. 1
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     stream.Position += 3;
 }
Esempio n. 2
0
        public new void LoadFrom(Stream stream)
        {
            base.LoadFrom(stream);

            BinaryReader reader = new BinaryReader(stream);
            m_Sprite = new PPtr<Sprite>(stream, file);
            m_Color = reader.ReadColor4();
        }
        public bool TryGet <TQuery, TResult>([NotNull] PPtr <TQuery> ptr, [CanBeNull] out TResult result)
            where TQuery : Object
            where TResult : TQuery
        {
            var b = TryGet(ptr.m_PathID, out var obj);

            if (!b)
            {
                result = null;
                return(false);
            }

            if (!(obj is TResult t))
            {
                result = null;
                return(false);
            }

            result = t;
            return(true);
        }
Esempio n. 4
0
        private AnimatorState(AssetInfo assetInfo, AnimatorController controller, int stateMachineIndex, int stateIndex, Vector3f position) :
            base(assetInfo, 1)
        {
            VirtualSerializedFile virtualFile = (VirtualSerializedFile)assetInfo.File;

            IReadOnlyDictionary <uint, string> TOS = controller.TOS;
            StateMachineConstant stateMachine      = controller.Controller.StateMachineArray[stateMachineIndex].Instance;
            StateConstant        state             = stateMachine.StateConstantArray[stateIndex].Instance;

            Name = TOS[state.NameID];

            Speed       = state.Speed;
            CycleOffset = state.CycleOffset;

            m_transitions = new PPtr <AnimatorStateTransition> [state.TransitionConstantArray.Count];
            for (int i = 0; i < state.TransitionConstantArray.Count; i++)
            {
                TransitionConstant      transitionConstant = state.TransitionConstantArray[i].Instance;
                AnimatorStateTransition transition         = AnimatorStateTransition.CreateVirtualInstance(virtualFile, controller, transitionConstant);
                m_transitions[i] = transition.File.CreatePPtr(transition);
            }

            m_stateMachineBehaviours = controller.GetStateBeahviours(stateMachineIndex, stateIndex);
            Position                   = position;
            IKOnFeet                   = state.IKOnFeet;
            WriteDefaultValues         = state.GetWriteDefaultValues(controller.File.Version);
            Mirror                     = state.Mirror;
            SpeedParameterActive       = state.SpeedParamID > 0;
            MirrorParameterActive      = state.MirrorParamID > 0;
            CycleOffsetParameterActive = state.CycleOffsetParamID > 0;
            TimeParameterActive        = state.TimeParamID > 0;

            Motion = state.CreateMotion(virtualFile, controller, 0);

            Tag                  = TOS[state.TagID];
            SpeedParameter       = TOS[state.SpeedParamID];
            MirrorParameter      = TOS[state.MirrorParamID];
            CycleOffsetParameter = TOS[state.CycleOffsetParamID];
            TimeParameter        = TOS[state.TimeParamID];
        }
        public AnimatorControllerLayers(AnimatorStateMachine stateMachine, AnimatorController controller, int layerIndex)
        {
            LayerConstant layer = controller.Controller.LayerArray[layerIndex].Instance;

            stateMachine.ParentStateMachinePosition = new Vector3f(800.0f, 20.0f, 0.0f);

            Name = controller.TOS[layer.Binding];

            StateMachine = PPtr <AnimatorStateMachine> .CreateVirtualPointer(stateMachine);

#warning TODO: animator
            Mask = default;

            m_motions                = new StateMotionPair[0];
            m_behaviours             = new StateBehavioursPair[0];
            BlendingMode             = layer.LayerBlendingMode;
            SyncedLayerIndex         = layer.StateMachineMotionSetIndex == 0 ? -1 : layer.StateMachineIndex;
            DefaultWeight            = layer.DefaultWeight;
            IKPass                   = layer.IKPass;
            SyncedLayerAffectsTiming = layer.SyncedLayerAffectsTiming;
            Controller               = new PPtr <AnimatorController>(controller);
        }
Esempio n. 6
0
 public                                                    PPtr <AnimatorTransition>[] GetEntryTransitions(VirtualSerializedFile file,
                                                                                                           AnimatorController controller, uint ID, IReadOnlyList <AnimatorState> states)
 {
     if (IsReadConstantArray(controller.File.Version))
     {
         foreach (OffsetPtr <SelectorStateConstant> selectorPtr in SelectorStateConstantArray)
         {
             SelectorStateConstant selector = selectorPtr.Instance;
             if (selector.FullPathID == ID && selector.IsEntry)
             {
                 PPtr <AnimatorTransition>[] transitions = new PPtr <AnimatorTransition> [selector.TransitionConstantArray.Count - 1];
                 for (int i = 0; i < selector.TransitionConstantArray.Count - 1; i++)
                 {
                     SelectorTransitionConstant selectorTrans = selector.TransitionConstantArray[i].Instance;
                     AnimatorTransition         transition    = new AnimatorTransition(file, controller, selectorTrans, states);
                     transitions[i] = PPtr <AnimatorTransition> .CreateVirtualPointer(transition);
                 }
                 return(transitions);
             }
         }
     }
     return(new PPtr <AnimatorTransition> [0]);
 }
 public AnimatorTransitionBase(AssetInfo assetsInfo) :
     base(assetsInfo)
 {
     DstStateMachine = new PPtr <AnimatorStateMachine>(AssetsFile);
     DstState        = new PPtr <AnimatorState>(AssetsFile);
 }
Esempio n. 8
0
 public GUIStyleState(bool _)
 {
     Background          = default;
     TextColor           = default;
     m_scaledBackgrounds = new PPtr <Texture2D> [0];
 }
Esempio n. 9
0
 public AnimatorStateMachine(AnimatorController controller) :
     base(CreateAssetsInfo(controller.AssetsFile))
 {
     DefaultState = new PPtr <AnimatorState>(AssetsFile);
 }
Esempio n. 10
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     stream.Position += 3;
     m_audioClip = new PPtr<AudioClip>(stream, file);
     m_PlayOnAwake = reader.ReadBoolean();
     stream.Position += 3;
     m_Volume = reader.ReadSingle();
     m_Pitch = reader.ReadSingle();
     Loop = reader.ReadBoolean();
     Mute = reader.ReadBoolean();
     stream.Position += 2;
     Priority = reader.ReadInt32();
     DopplerLevel = reader.ReadSingle();
     MinDistance = reader.ReadSingle();
     MaxDistance = reader.ReadSingle();
     Pan2D = reader.ReadSingle();
     rolloffMode = reader.ReadInt32();
     BypassEffects = reader.ReadBoolean();
     BypassListenerEffects = reader.ReadBoolean();
     BypassReverbZones = reader.ReadBoolean();
     stream.Position += 1;
     rolloffCustomCurve = new AnimationCurve<float>(reader, reader.ReadSingle);
     panLevelCustomCurve = new AnimationCurve<float>(reader, reader.ReadSingle);
     spreadCustomCurve = new AnimationCurve<float>(reader, reader.ReadSingle);
 }
 public AnimationClipBindingConstant(bool _)
 {
     m_genericBindings  = new GenericBinding[0];
     m_pptrCurveMapping = new PPtr <Object> [0];
 }
Esempio n. 12
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     enabled = reader.ReadBoolean();
     reader.ReadBytes(3);
     type = reader.ReadInt32();
     radius = reader.ReadSingle();
     angle = reader.ReadSingle();
     length = reader.ReadSingle();
     boxX = reader.ReadSingle();
     boxY = reader.ReadSingle();
     boxZ = reader.ReadSingle();
     placementMode = reader.ReadInt32();
     m_Mesh = new PPtr<Mesh>(stream, file);
     randomDirection = reader.ReadBoolean();
     reader.ReadBytes(3);
 }
Esempio n. 13
0
 public override void LoadFrom(Stream stream)
 {
     Value = new PPtr<Object>(stream, file);
 }
Esempio n. 14
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     stream.Position += 3;
     m_NearClipPlane = reader.ReadSingle();
     m_FarClipPlane = reader.ReadSingle();
     m_FieldOfView = reader.ReadSingle();
     m_AspectRatio = reader.ReadSingle();
     m_Orthographic = reader.ReadBoolean();
     stream.Position += 3;
     m_OrthographicSize = reader.ReadSingle();
     m_Material = new PPtr<Material>(stream, file);
     m_IgnoreLayers = new BitField(stream);
 }
Esempio n. 15
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            texture = new PPtr<Texture2D>(stream, file);

            int numVertices = reader.ReadInt32();
            vertices = new SpriteVertex[numVertices];
            for (int i = 0; i < numVertices; i++)
            {
                vertices[i] = new SpriteVertex(stream);
            }

            int numIndices = reader.ReadInt32();
            indices = reader.ReadUInt16Array(numIndices);
            if ((numIndices & 1) > 0)
            {
                reader.ReadBytes(2);
            }

            textureRect = new Rectf(stream);
            textureRectOffset = reader.ReadVector2();
            settingsRaw = reader.ReadUInt32();
            uvTransform = reader.ReadVector4();
        }
Esempio n. 16
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     reader.ReadBytes(3);
     m_Avatar = new PPtr<Avatar>(stream, file);
     m_Controller = new PPtr<RuntimeAnimatorController>(stream);
     m_CullingMode = reader.ReadInt32();
     m_UpdateMode = reader.ReadInt32();
     m_ApplyRootMotion = reader.ReadInt32();
     m_HasTransformHierarchy = reader.ReadBoolean();
     m_AllowConstantClipSamplingOptimization = reader.ReadBoolean();
 }
Esempio n. 17
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Material = new PPtr<Material>(stream, file);
     m_IsTrigger = reader.ReadBoolean();
     m_Enabled = reader.ReadBoolean();
     stream.Position += 2;
     m_Radius = reader.ReadSingle();
     m_Height = reader.ReadSingle();
     m_Direction = reader.ReadInt32();
     m_Center = reader.ReadVector3();
 }
Esempio n. 18
0
 public Animator(AssetPreloadData preloadData) : base(preloadData)
 {
     m_Avatar     = sourceFile.ReadPPtr();
     m_Controller = sourceFile.ReadPPtr();
 }
Esempio n. 19
0
 protected Component(AssetPreloadData preloadData) : base(preloadData)
 {
     m_GameObject = sourceFile.ReadPPtr();
 }
Esempio n. 20
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     stream.Position += 3;
     m_ClearFlags = reader.ReadUInt32();
     m_BackGroundColor = reader.ReadColor4();
     m_NormalizedViewPortRect = new Rectf(stream);
     near_clip_plane = reader.ReadSingle();
     far_clip_plane = reader.ReadSingle();
     field_of_view = reader.ReadSingle();
     orthographic = reader.ReadBoolean();
     stream.Position += 3;
     orthographic_size = reader.ReadSingle();
     m_Depth = reader.ReadSingle();
     m_CullingMask = new BitField(stream);
     m_RenderingPath = reader.ReadInt32();
     m_TargetTexture = new PPtr<Texture2D>(stream, file);
     m_TargetDisplay = reader.ReadUInt32();
     m_HDR = reader.ReadBoolean();
     m_OcclusionCulling = reader.ReadBoolean();
     stream.Position += 2;
     m_StereoConvergence = reader.ReadSingle();
     m_StereoSeparation = reader.ReadSingle();
 }
Esempio n. 21
0
        private void TryInitialize(ProjectAssetContainer container)
        {
            if (m_initialized)
            {
                return;
            }

            AnimatorController asset      = (AnimatorController)Asset;
            ControllerConstant controller = asset.Controller;
            IReadOnlyList <OffsetPtr <StateMachineConstant> > stateMachinesConst = controller.StateMachineArray;

            m_stateMachines = new AnimatorStateMachine[stateMachinesConst.Count];
            for (int i = 0; i < stateMachinesConst.Count; i++)
            {
                StateMachineConstant stateMachineConstant = stateMachinesConst[i].Instance;
                AnimatorStateMachine stateMachine         = new AnimatorStateMachine(container.VirtualFile, asset, i);
                m_stateMachines[i] = stateMachine;
            }

            for (int i = 0; i < StateMachines.Count; i++)
            {
                AnimatorStateMachine stateMachine         = StateMachines[i];
                StateMachineConstant stateMachineConstant = asset.Controller.StateMachineArray[i].Instance;
                AddAsset(stateMachine);

                foreach (PPtr <AnimatorStateTransition> transitionPtr in stateMachine.AnyStateTransitions)
                {
                    AnimatorStateTransition transition = transitionPtr.GetAsset(container.VirtualFile);
                    AddAsset(transition);
                }
                foreach (PPtr <AnimatorTransition> transitionPtr in stateMachine.EntryTransitions)
                {
                    AnimatorTransition transition = transitionPtr.GetAsset(container.VirtualFile);
                    AddAsset(transition);
                }

                for (int j = 0; j < stateMachine.ChildStates.Count; j++)
                {
                    PPtr <AnimatorState> statePtr      = stateMachine.ChildStates[j].State;
                    AnimatorState        state         = statePtr.GetAsset(container.VirtualFile);
                    StateConstant        stateConstant = stateMachineConstant.StateConstantArray[j].Instance;
                    AddAsset(state);

                    if (state.Motion.IsVirtual)
                    {
                        AddBlendTree(container.VirtualFile, state.Motion.CastTo <BlendTree>());
                    }

                    for (int k = 0; k < state.Transitions.Count; k++)
                    {
                        PPtr <AnimatorStateTransition> transitionPtr      = state.Transitions[k];
                        AnimatorStateTransition        transition         = transitionPtr.GetAsset(container.VirtualFile);
                        TransitionConstant             transitionConstant = stateConstant.TransitionConstantArray[k].Instance;

                        AddAsset(transition);
                    }
                }
            }

            m_initialized = true;
        }
Esempio n. 22
0
        private AnimatorStateMachine(AssetInfo assetInfo, AnimatorController controller, int stateMachineIndex) :
            base(assetInfo, 1)
        {
            VirtualSerializedFile virtualFile = (VirtualSerializedFile)assetInfo.File;

            LayerConstant layer = controller.Controller.GetLayerByStateMachineIndex(stateMachineIndex);

            Name = controller.TOS[layer.Binding];

            StateMachineConstant stateMachine = controller.Controller.StateMachineArray[stateMachineIndex].Instance;

            int stateCount        = stateMachine.StateConstantArray.Count;
            int stateMachineCount = 0;
            int count             = stateCount + stateMachineCount;
            int side = (int)Math.Ceiling(Math.Sqrt(count));

            List <AnimatorState> states = new List <AnimatorState>();

            m_childStates = new ChildAnimatorState[stateCount];
            for (int y = 0, stateIndex = 0; y < side && stateIndex < stateCount; y++)
            {
                for (int x = 0; x < side && stateIndex < stateCount; x++, stateIndex++)
                {
                    Vector3f           position   = new Vector3f(x * StateOffset, y * StateOffset, 0.0f);
                    AnimatorState      state      = AnimatorState.CreateVirtualInstance(virtualFile, controller, stateMachineIndex, stateIndex, position);
                    ChildAnimatorState childState = new ChildAnimatorState(state, position);
                    m_childStates[stateIndex] = childState;
                    states.Add(state);
                }
            }
#warning TODO: child StateMachines
            m_childStateMachines = new ChildAnimatorStateMachine[stateMachineCount];

            // set destination state for transitions here because all states has become valid only now
            for (int i = 0; i < stateMachine.StateConstantArray.Count; i++)
            {
                AnimatorState state         = states[i];
                StateConstant stateConstant = stateMachine.StateConstantArray[i].Instance;
                PPtr <AnimatorStateTransition>[] transitions = new PPtr <AnimatorStateTransition> [stateConstant.TransitionConstantArray.Count];
                for (int j = 0; j < stateConstant.TransitionConstantArray.Count; j++)
                {
                    TransitionConstant transitionConstant         = stateConstant.TransitionConstantArray[j].Instance;
                    AnimatorStateTransition.Parameters parameters = new AnimatorStateTransition.Parameters
                    {
                        StateMachine = stateMachine,
                        States       = states,
                        TOS          = controller.TOS,
                        Transition   = transitionConstant,
                        Version      = controller.File.Version,
                    };
                    AnimatorStateTransition transition = AnimatorStateTransition.CreateVirtualInstance(virtualFile, parameters);
                    transitions[j] = transition.File.CreatePPtr(transition);
                }
                state.Transitions = transitions;
            }

            m_anyStateTransitions = new PPtr <AnimatorStateTransition> [stateMachine.AnyStateTransitionConstantArray.Count];
            for (int i = 0; i < stateMachine.AnyStateTransitionConstantArray.Count; i++)
            {
                TransitionConstant transitionConstant         = stateMachine.AnyStateTransitionConstantArray[i].Instance;
                AnimatorStateTransition.Parameters parameters = new AnimatorStateTransition.Parameters
                {
                    StateMachine = stateMachine,
                    States       = states,
                    TOS          = controller.TOS,
                    Transition   = transitionConstant,
                    Version      = controller.File.Version,
                };
                AnimatorStateTransition transition = AnimatorStateTransition.CreateVirtualInstance(virtualFile, parameters);
                m_anyStateTransitions[i] = transition.File.CreatePPtr(transition);
            }

            StateMachineConstant.Parameters stateParameters = new StateMachineConstant.Parameters
            {
                ID      = layer.Binding,
                States  = states,
                TOS     = controller.TOS,
                Version = controller.File.Version,
            };
            m_entryTransitions       = stateMachine.CreateEntryTransitions(virtualFile, stateParameters);
            m_stateMachineBehaviours = new PPtr <MonoBehaviour> [0];

            AnyStatePosition           = new Vector3f(0.0f, -StateOffset, 0.0f);
            EntryPosition              = new Vector3f(StateOffset, -StateOffset, 0.0f);
            ExitPosition               = new Vector3f(2.0f * StateOffset, -StateOffset, 0.0f);
            ParentStateMachinePosition = new Vector3f(0.0f, -2.0f * StateOffset, 0.0f);

            DefaultState = ChildStates.Count > 0 ? ChildStates[stateMachine.DefaultState].State : default;
        }
Esempio n. 23
0
 public SubEmitterData(PPtr <ParticleSystem> emitter, ParticleSystemSubEmitterType type)
 {
     Emitter    = emitter;
     Type       = type;
     Properties = ParticleSystemSubEmitterProperties.InheritNothing;
 }
Esempio n. 24
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            m_Name = reader.ReadNameA4();
            m_Shader = new PPtr<Shader>(stream, file);

            int numShaderKeywords = reader.ReadInt32();
            m_ShaderKeywords = new List<string>(numShaderKeywords);
            for (int i = 0; i < numShaderKeywords; i++)
            {
                m_ShaderKeywords.Add(reader.ReadNameA4());
            }

            m_CustomRenderQueue = reader.ReadInt32();
            m_SavedProperties = new UnityPropertySheet(file, stream);
        }
Esempio n. 25
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     enabled = reader.ReadBoolean();
     reader.ReadBytes(3);
     type = reader.ReadInt32();
     plane0 = new PPtr<Transform>(stream, file);
     plane1 = new PPtr<Transform>(stream, file);
     plane2 = new PPtr<Transform>(stream, file);
     plane3 = new PPtr<Transform>(stream, file);
     plane4 = new PPtr<Transform>(stream, file);
     plane5 = new PPtr<Transform>(stream, file);
     dampen = reader.ReadSingle();
     bounce = reader.ReadSingle();
     energyLossOnCollision = reader.ReadSingle();
     minKillSpeed = reader.ReadSingle();
     particleRadius = reader.ReadSingle();
     collidesWith = new BitField(stream);
     quality = reader.ReadInt32();
     voxelSize = reader.ReadSingle();
     collisionMessages = reader.ReadBoolean();
     reader.ReadBytes(3);
 }
Esempio n. 26
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_Texture = new PPtr<Texture2D>(stream, file);
     m_Scale = reader.ReadVector2();
     m_Offset = reader.ReadVector2();
 }
Esempio n. 27
0
 public AnimatorTransition(VirtualSerializedFile file, AnimatorController controller, SelectorTransitionConstant transition,
                           IReadOnlyList <AnimatorState> states) :
     this(file, controller, transition)
 {
     DstState = PPtr <AnimatorState> .CreateVirtualPointer(states[transition.Destination]);
 }
Esempio n. 28
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Mass = reader.ReadSingle();
     m_Drag = reader.ReadSingle();
     m_AngularDrag = reader.ReadSingle();
     m_UseGravity = reader.ReadBoolean();
     m_IsKinematic = reader.ReadBoolean();
     m_Interpolate = reader.ReadByte();
     stream.Position += 1;
     m_Constraints = reader.ReadInt32();
     m_CollisionDetection = reader.ReadInt32();
 }
Esempio n. 29
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     Does_Animate_Color = reader.ReadBoolean();
     reader.ReadBytes(3);
     colorAnimation = reader.ReadUInt32Array(5);
     worldRotationAxis = reader.ReadVector3();
     localRotationAxis = reader.ReadVector3();
     sizeGrow = reader.ReadSingle();
     rndForce = reader.ReadVector3();
     force = reader.ReadVector3();
     damping = reader.ReadSingle();
     stopSimulation = reader.ReadBoolean();
     autodestruct = reader.ReadBoolean();
 }
Esempio n. 30
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            m_Name = reader.ReadNameA4();

            int numObjects = reader.ReadInt32();
            m_PreloadTable = new List<PPtr<Object>>(numObjects);
            for (int i = 0; i < numObjects; i++)
            {
                PPtr<Object> objPtr = new PPtr<Object>(stream);
                if (objPtr.m_FileID == 0)
                {
                    Component comp = file.FindComponent(objPtr.m_PathID, false);
                    if (comp == null)
                    {
                        comp = new NotLoaded(file, objPtr.m_PathID, 0, 0);
                    }
                    objPtr = new PPtr<Object>(comp);
                }
                m_PreloadTable.Add(objPtr);
            }

            int numContainerEntries = reader.ReadInt32();
            m_Container = new List<KeyValuePair<string, AssetInfo>>(numContainerEntries);
            for (int i = 0; i < numContainerEntries; i++)
            {
                m_Container.Add
                (
                    new KeyValuePair<string, AssetInfo>
                    (
                        reader.ReadNameA4(), new AssetInfo(file, stream)
                    )
                );
            }

            m_MainAsset = new AssetInfo(file, stream);

            int numScriptComps = reader.ReadInt32();
            m_ScriptCompatibility = new AssetBundleScriptInfo[numScriptComps];
            for (int i = 0; i < numScriptComps; i++)
            {
                m_ScriptCompatibility[i] = new AssetBundleScriptInfo(stream);
            }

            int numClassComps = reader.ReadInt32();
            m_ClassCompatibility = new KeyValuePair<int, uint>[numClassComps];
            for (int i = 0; i < numClassComps; i++)
            {
                m_ClassCompatibility[i] = new KeyValuePair<int, uint>
                (
                    reader.ReadInt32(), reader.ReadUInt32()
                );
            }

            m_RuntimeCompatibility = reader.ReadUInt32();
        }
Esempio n. 31
0
        protected virtual void Load(ArchiveBinaryReader reader)
        {
            try
            {
                long startPos   = reader.BaseStream.Position;
                int  headerSize = reader.ReadInt32(true);
                var  fileSize   = reader.ReadInt32(true);
                this.Format          = reader.ReadInt32(true);
                this.assetDataOffset = reader.ReadUInt32(true);

                if (this.Format < 17)
                {
                    throw new NotSupportedException(string.Format("The AssetBundle's format not supported,format:{0}", this.Format));
                }

                bool bigEndian = reader.ReadBoolean();
                reader.IsBigEndian = bigEndian;
                reader.ReadBytes(3);
                this.Version        = reader.ReadCString();
                this.TargetPlatform = reader.ReadUInt32();

                //读取类型树
                var hasTypeTree = reader.ReadBoolean();
                if (!hasTypeTree)
                {
                    throw new NotSupportedException("Missing type tree, not supported");
                }

                Hash128 zero          = new Hash128(new byte[16]);
                var     typeTreeCount = reader.ReadInt32();
                for (var i = 0; i < typeTreeCount; i++)
                {
                    var typeId = reader.ReadInt32();
                    reader.ReadByte();
                    var scriptIndex    = reader.ReadInt16();
                    var hash           = reader.ReadHash128();
                    var propertiesHash = typeId == 114 ? reader.ReadHash128() : zero;
                    var tree           = new TypeTree(this, i, Enum.IsDefined(typeof(TypeID), typeId) ? (TypeID)typeId : TypeID.UnknownType, scriptIndex, hash, propertiesHash);
                    tree.Load(reader);
                    this.trees.Add(tree);
                }

                //读取对象信息
                var objectCount = reader.ReadInt32();
                List <ObjectItem> objectItems = new List <ObjectItem>();
                for (var i = 0; i < objectCount; i++)
                {
                    reader.Align(4);
                    var id       = reader.ReadInt64();
                    var offset   = reader.ReadInt32();
                    var size     = reader.ReadInt32();
                    var index    = reader.ReadInt32();
                    var typeTree = trees[index];
                    var item     = new ObjectItem(id, offset, size, typeTree);
                    objectItems.Add(item);
                }

                //自定义脚本预载表
                var scriptCount = reader.ReadInt32();
                for (int i = 0; i < scriptCount; i++)
                {
                    var fileID = reader.ReadInt32();
                    var pathID = reader.ReadInt64();
                    var pptr   = new PPtr(fileID, pathID, "PPtr<MonoScript>");
                    this.preloadScripts.Add(pptr);
                }

                //读取共享对象
                int refCount = reader.ReadInt32();
                for (int i = 1; i <= refCount; i++)
                {
                    var name     = reader.ReadCString();
                    var guid     = reader.ReadHash128();
                    var type     = reader.ReadInt32();
                    var fileName = reader.ReadCString();
                    fileName = string.IsNullOrEmpty(fileName) ? "" : fileName.ToLower();
                    var assetRef = new ArchiveRef(i, name, type, guid, fileName);
                    this.archiveRefs.Add(assetRef);
                }

                foreach (var item in objectItems)
                {
                    TypeID typeId = item.TypeTree.TypeID;
                    if (typeId != TypeID.AssetBundle && typeId != TypeID.PreloadData)
                    {
                        continue;
                    }

                    ObjectInfo info = new ObjectInfo(this, item.ID, item.TypeTree, item.Offset, item.Size, false);
                    if (info.TypeID == TypeID.AssetBundle)
                    {
                        AssetBundle assetBundle = info.GetObject <AssetBundle>();
                        this.AssetBundle   = assetBundle;
                        Bundle.AssetBundle = assetBundle;
                    }
                    else if (info.TypeID == TypeID.PreloadData)
                    {
                        PreloadData preloadData = info.GetObject <PreloadData>();
                        this.PreloadData = preloadData;
                    }
                }

                foreach (var item in objectItems)
                {
                    TypeID typeId = item.TypeTree.TypeID;
                    if (typeId == TypeID.AssetBundle || typeId == TypeID.PreloadData)
                    {
                        continue;
                    }

                    bool       isPublic = !this.Bundle.IsStreamed && this.AssetBundle != null && this.AssetBundle.IsPublic(item.ID);
                    ObjectInfo info     = new ObjectInfo(this, item.ID, item.TypeTree, item.Offset, item.Size, isPublic);
                    this.objects.Add(info.ID, info);

                    if (info.IsPotentialRedundancy)
                    {
                        reader.BaseStream.Seek(this.assetDataOffset + item.Offset, SeekOrigin.Begin);
                        FeatureInfo featureInfo = this.extractor.Extract(info, reader);
                        info.Fingerprint = new PropertiesFingerprint(info, featureInfo.References, featureInfo.PropertyHash);
                        info.Name        = featureInfo.Name;
                        info.Resources   = featureInfo.Resources;
                    }
                    else
                    {
                        info.Fingerprint = new IdentifierFingerprint(info.ID, this.Name);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogErrorFormat("{0}", e);
            }
        }
Esempio n. 32
0
        public void ReplaceComponent(Component oldAsset, Component newAsset)
        {
            for (int i = 0; i < m_PreloadTable.Count; i++)
            {
                if (m_PreloadTable[i] != null &&
                    (m_PreloadTable[i].asset is NotLoaded &&
                        (((NotLoaded)m_PreloadTable[i].asset).replacement == oldAsset
                        || m_PreloadTable[i].asset.pathID == oldAsset.pathID)
                    || m_PreloadTable[i].asset == oldAsset))
                {
                    m_PreloadTable[i] = new PPtr<Object>(newAsset);
                }
            }

            for (int i = 0; i < m_Container.Count; i++)
            {
                if (m_Container[i].Value.asset.asset is NotLoaded &&
                        (((NotLoaded)m_Container[i].Value.asset.asset).replacement == oldAsset
                        || m_Container[i].Value.asset.asset.pathID == oldAsset.pathID)
                    || m_Container[i].Value.asset.asset == oldAsset)
                {
                    m_Container[i].Value.asset = new PPtr<Object>(newAsset);
                }
            }
        }
Esempio n. 33
0
 public T Get <T>([NotNull] PPtr <T> ptr)
     where T : Object
 {
     return(Get <T, T>(ptr));
 }
Esempio n. 34
0
 private static void AddExternalAsset(List<Component> assets, PPtr<Shader> dep)
 {
     Component found = assets.Find
     (
         delegate(Component c)
         {
             if (c is ExternalAsset)
             {
                 ExternalAsset e = (ExternalAsset)c;
                 return e.FileID == dep.m_FileID && e.PathID == dep.m_PathID;
             }
             return false;
         }
     );
     if (found == null)
     {
         ExternalAsset extShader = new ExternalAsset();
         extShader.FileID = dep.m_FileID;
         extShader.PathID = dep.m_PathID;
         assets.Add(extShader);
     }
 }
Esempio n. 35
0
        public object Parse(TypeNode typeNode, ArchiveBinaryReader reader)
        {
            object result = null;

            switch (typeNode.TypeFlag)
            {
            case "bool":
                result = reader.ReadBoolean();
                break;

            case "SInt8":
                result = reader.ReadSByte();
                break;

            case "char":
            case "UInt8":
                result = reader.ReadByte();
                break;

            case "short":
            case "SInt16":
                result = reader.ReadInt16();
                break;

            case "unsigned short":
            case "UInt16":
                result = reader.ReadUInt16();
                break;

            case "int":
            case "SInt32":
                result = reader.ReadInt32();
                break;

            case "unsigned int":
            case "UInt32":
            case "Type*":
                result = reader.ReadUInt32();
                break;

            case "long long":
            case "SInt64":
                result = reader.ReadInt64();
                break;

            case "unsigned long long":
            case "UInt64":
                result = reader.ReadUInt64();
                break;

            case "float":
                result = reader.ReadSingle();
                break;

            case "double":
                result = reader.ReadDouble();
                break;

            case "Quaternionf":
            {
                result = reader.ReadQuaternion();
                break;
            }

            case "float4":
            case "Vector4f":
            {
                result = reader.ReadVector4();
                break;
            }

            case "float3":
            case "Vector3f":
            {
                result = reader.ReadVector3();
                break;
            }

            case "float2":
            case "Vector2f":
            {
                result = reader.ReadVector2();
                break;
            }

            case "ColorRGBA":
            {
                if (typeNode.Version == 2)
                {
                    result = reader.ReadColor32();
                }
                else
                {
                    result = reader.ReadColor();
                }
                break;
            }

            case "Matrix4x4f":
            {
                result = reader.ReadMatrix4x4();
                break;
            }

            case "Hash128":
            {
                result = reader.ReadHash128();
                break;
            }

            case "string":
            {
                result = reader.ReadString();
                break;
            }

            case "vector":
            case "staticvector":
            case "set":
            {
                var valueTypeNode = typeNode.Children[0];
                result = this.Parse(valueTypeNode, reader);
                break;
            }

            case "map":
            {
                var pairTypeNode  = typeNode.Children[0].Children[1];
                var keyTypeNode   = pairTypeNode.Children[0];
                var valueTypeNode = pairTypeNode.Children[1];

                var size = reader.ReadInt32();
                Map map  = new Map(typeNode);
                for (int i = 0; i < size; i++)
                {
                    var key   = this.Parse(keyTypeNode, reader);
                    var value = this.Parse(valueTypeNode, reader);
                    map.Add(key, value);
                }
                result = map;
                break;
            }

            case "Array":
            {
                var valueTypeNode = typeNode.Children[1];
                var size          = reader.ReadInt32();
                result = this.ParseArray(valueTypeNode, size, reader);
                break;
            }

            case "PPtr":
            {
                var fileID = reader.ReadInt32();
                var pathID = reader.ReadInt64();
                result = new PPtr(fileID, pathID, typeNode.TypeName);
                break;
            }

            case "TypelessData":
            {
                var size = reader.ReadInt32();
                result = new TypelessData(reader.ReadBytes(size));
                break;
            }

            case "StreamedResource":
            {
                var source           = reader.ReadString();
                var offset           = reader.ReadUInt64();
                var size             = reader.ReadUInt64();
                var streamedResource = new StreamedResource(source, offset, size);
                result = streamedResource;
                break;
            }

            case "AssetBundle":
            {
                AssetBundle bundle = new AssetBundle(((TypeTree)typeNode).Archive);
                bundle.FullName = reader.ReadString();

                var         size         = reader.ReadInt32();
                List <PPtr> preloadTable = new List <PPtr>(size);
                for (int i = 0; i < size; i++)
                {
                    PPtr pptr = new PPtr(reader.ReadInt32(), reader.ReadInt64(), "PPtr<Object>");
                    preloadTable.Add(pptr);
                }

                bundle.Preloads.AddRange(preloadTable);

                size = reader.ReadInt32();
                List <AssetPair> container = new List <AssetPair>(size);
                for (int i = 0; i < size; i++)
                {
                    var first        = reader.ReadString();
                    var preloadIndex = reader.ReadInt32();
                    var preloadSize  = reader.ReadInt32();
                    var pptr         = new PPtr(reader.ReadInt32(), reader.ReadInt64(), "PPtr<Object>");
                    var pair         = new AssetPair(first, new Objects.AssetInfo(preloadIndex, preloadSize, pptr));
                    container.Add(pair);
                }
                bundle.Container.AddRange(container);

                bundle.MainAsset = new Objects.AssetInfo(reader.ReadInt32(), reader.ReadInt32(), new PPtr(reader.ReadInt32(), reader.ReadInt64(), "PPtr<Object>"));

                bundle.RuntimeCompatibility = reader.ReadUInt32();
                bundle.Name = reader.ReadString();

                size = reader.ReadInt32();
                List <string> dependencies = new List <string>(size);
                for (int i = 0; i < size; i++)
                {
                    dependencies.Add(reader.ReadString());
                }
                bundle.Dependencies.AddRange(dependencies);

                bundle.IsStreamed = reader.ReadBoolean();
                result            = bundle;
                break;
            }

            case "PreloadData":
            {
                PreloadData preloadData = new PreloadData(((TypeTree)typeNode).Archive);

                preloadData.Name = reader.ReadString();

                var         size         = reader.ReadInt32();
                List <PPtr> preloadTable = new List <PPtr>(size);
                for (int i = 0; i < size; i++)
                {
                    PPtr pptr = new PPtr(reader.ReadInt32(), reader.ReadInt64(), "PPtr<Object>");
                    preloadTable.Add(pptr);
                }

                preloadData.Preloads.AddRange(preloadTable);

                size = reader.ReadInt32();
                List <string> dependencies = new List <string>(size);
                for (int i = 0; i < size; i++)
                {
                    dependencies.Add(reader.ReadString());
                }
                preloadData.Dependencies.AddRange(dependencies);
                result = preloadData;
                break;
            }

            case "AssetBundleManifest":
            {
                Objects.AssetBundleManifest obj = new Objects.AssetBundleManifest((TypeTree)typeNode);
                foreach (TypeNode childNode in typeNode.Children)
                {
                    var key        = childNode.FieldName;
                    var childValue = this.Parse(childNode, reader);
                    obj[key] = childValue;
                }
                result = obj;
                break;
            }

            default:
            {
                DynamicObject obj = typeNode is TypeTree ? new UnityDynamicObject((TypeTree)typeNode) : new DynamicObject(typeNode);
                foreach (TypeNode childNode in typeNode.Children)
                {
                    var key        = childNode.FieldName;
                    var childValue = this.Parse(childNode, reader);
                    obj[key] = childValue;
                }
                result = obj;
                break;
            }
            }

            if (typeNode.IsAlign)
            {
                reader.Align(4);
            }

            return(result);
        }
Esempio n. 36
0
        private void UpdateComponent(Component asset, List<Tuple<List<PPtr<Object>>, List<KeyValuePair<string, AssetInfo>>>> containerGroups)
        {
            List<Component> assets = new List<Component>();
            List<Component> transforms = new List<Component>();
            List<Component> containerRelated = new List<Component>();
            GetDependantAssets(asset, assets, transforms, containerRelated);
            if (asset.classID1 == UnityClassID.GameObject)
            {
                GameObject gameObj = (GameObject)asset;
                Animator animator = gameObj.FindLinkedComponent(UnityClassID.Animator);
                if (animator == null)
                {
                    foreach (Component trans in transforms)
                    {
                        GetDependantAssets(trans, assets, null, null);
                    }
                    animator = new Animator(null, 0, UnityClassID.Animator, UnityClassID.Animator);
                    animator.m_Avatar = new PPtr<Avatar>((Component)null);
                    animator.m_Controller = new PPtr<RuntimeAnimatorController>((Component)null);
                    GetDependantAssets(animator, assets, transforms, containerRelated);
                    assets.Remove(animator);
                }
            }
            foreach (var group in containerGroups)
            {
                var preloadPart = group.Item1;
                var containerEntries = group.Item2;
                for (int i = 0; i < containerEntries.Count; i++)
                {
                    var assetPair = containerEntries[i];
                    if (assetPair.Value.asset.asset == asset)
                    {
                        preloadPart.Clear();
                        for (int j = 0; j < assets.Count; j++)
                        {
                            if (assets[j] is ExternalAsset)
                            {
                                ExternalAsset extAsset = (ExternalAsset)assets[j];
                                PPtr<Object> preloadEntry = new PPtr<Object>((Component)null);
                                preloadEntry.m_FileID = extAsset.FileID;
                                preloadEntry.m_PathID = extAsset.PathID;
                                preloadPart.Add(preloadEntry);
                            }
                            else
                            {
                                preloadPart.Add(new PPtr<Object>(assets[j]));
                            }
                        }

                        string groupName = containerEntries[0].Key;
                        string assetName = AssetCabinet.ToString(asset);
                        if (String.Compare(groupName, assetName, true) != 0)
                        {
                            groupName = assetName.ToLower();
                        }
                        if (containerEntries.Count > 1)
                        {
                            for (int j = 0; j < containerEntries.Count; j++)
                            {
                                switch (containerEntries[j].Value.asset.asset.classID1)
                                {
                                case UnityClassID.Mesh:
                                case UnityClassID.AnimationClip:
                                    containerEntries.RemoveAt(j);
                                    j--;
                                    break;
                                }
                            }
                            for (int j = containerRelated.Count - 1; j >= 0; j--)
                            {
                                AnimationClip clip = containerRelated[j] as AnimationClip;
                                if (clip != null)
                                {
                                    AssetInfo info = new AssetInfo(file);
                                    info.asset = new PPtr<Object>(clip);
                                    containerEntries.Insert(1, new KeyValuePair<string, AssetInfo>(groupName, info));
                                }
                            }
                            for (int j = containerRelated.Count - 1; j >= 0; j--)
                            {
                                MeshRenderer meshR = containerRelated[j] as MeshRenderer;
                                if (meshR != null)
                                {
                                    Mesh mesh = Operations.GetMesh(meshR);
                                    if (mesh != null)
                                    {
                                        AssetInfo info = new AssetInfo(file);
                                        info.asset = new PPtr<Object>(mesh);
                                        containerEntries.Insert(1, new KeyValuePair<string, AssetInfo>(groupName, info));
                                    }
                                }
                            }
                            for (int j = 0; j < containerEntries.Count; j++)
                            {
                                containerEntries[j].Value.preloadSize = assets.Count;
                            }
                        }
                        else
                        {
                            containerEntries[0].Value.preloadSize = assets.Count;
                        }
                        for (int j = 0; j < containerEntries.Count; j++)
                        {
                            if (containerEntries[j].Key != groupName)
                            {
                                containerEntries[j] = new KeyValuePair<string, AssetInfo>(groupName, containerEntries[j].Value);
                            }
                        }
                        return;
                    }
                }
            }
        }
Esempio n. 37
0
 public AnimatorControllerParameter(IAssetsFile assetsFile)
 {
     DefaultController = new PPtr <AnimatorController>(assetsFile);
 }
 public MonoBehaviour(AssetPreloadData preloadData) : base(preloadData)
 {
     m_Script = sourceFile.ReadPPtr();
     m_Name   = reader.ReadAlignedString();
 }
Esempio n. 39
0
        public AnimatorStateMachine(VirtualSerializedFile file, AnimatorController controller, int stateMachineIndex) :
            base(file.CreateAssetInfo(ClassIDType.AnimatorStateMachine))
        {
            ObjectHideFlags = 1;

            LayerConstant layer = controller.Controller.GetLayerByStateMachineIndex(stateMachineIndex);

            Name = controller.TOS[layer.Binding];

            StateMachineConstant stateMachine = controller.Controller.StateMachineArray[stateMachineIndex].Instance;

            int stateCount        = stateMachine.StateConstantArray.Count;
            int stateMachineCount = 0;
            int count             = stateCount + stateMachineCount;
            int side = (int)Math.Ceiling(Math.Sqrt(count));

            List <AnimatorState> states = new List <AnimatorState>();

            m_childStates = new ChildAnimatorState[stateCount];
            for (int y = 0, stateIndex = 0; y < side && stateIndex < stateCount; y++)
            {
                for (int x = 0; x < side && stateIndex < stateCount; x++, stateIndex++)
                {
                    Vector3f           position   = new Vector3f(x * StateOffset, y * StateOffset, 0.0f);
                    AnimatorState      state      = new AnimatorState(file, controller, stateMachineIndex, stateIndex, position);
                    ChildAnimatorState childState = new ChildAnimatorState(state, position);
                    m_childStates[stateIndex] = childState;
                    states.Add(state);
                }
            }
            m_childStateMachines = new ChildAnimatorStateMachine[stateMachineCount];

            // set destination state for transitions here because all states has become valid only now
            for (int i = 0; i < stateMachine.StateConstantArray.Count; i++)
            {
                AnimatorState state         = states[i];
                StateConstant stateConstant = stateMachine.StateConstantArray[i].Instance;
                for (int j = 0; j < stateConstant.TransitionConstantArray.Count; j++)
                {
                    long stateTransitionPath                   = state.Transitions[j].PathID;
                    AnimatorStateTransition transition         = (AnimatorStateTransition)file.GetAsset(stateTransitionPath);
                    TransitionConstant      transitionConstant = stateConstant.TransitionConstantArray[j].Instance;
                    if (!transitionConstant.IsExit)
                    {
                        AnimatorState destState = states[transitionConstant.DestinationState];
                        transition.DstState = PPtr <AnimatorState> .CreateVirtualPointer(destState);
                    }
                }
            }

            m_anyStateTransitions = new PPtr <AnimatorStateTransition> [stateMachine.AnyStateTransitionConstantArray.Count];
            for (int i = 0; i < stateMachine.AnyStateTransitionConstantArray.Count; i++)
            {
                TransitionConstant      transitionConstant = stateMachine.AnyStateTransitionConstantArray[i].Instance;
                AnimatorStateTransition transition         = new AnimatorStateTransition(file, controller, transitionConstant, states);
                m_anyStateTransitions[i] = PPtr <AnimatorStateTransition> .CreateVirtualPointer(transition);
            }

            m_entryTransitions       = stateMachine.GetEntryTransitions(file, controller, layer.Binding, states);
            m_stateMachineBehaviours = new PPtr <MonoBehaviour> [0];

            AnyStatePosition           = new Vector3f(0.0f, -StateOffset, 0.0f);
            EntryPosition              = new Vector3f(StateOffset, -StateOffset, 0.0f);
            ExitPosition               = new Vector3f(2.0f * StateOffset, -StateOffset, 0.0f);
            ParentStateMachinePosition = new Vector3f(0.0f, -2.0f * StateOffset, 0.0f);

            DefaultState = ChildStates.Count > 0 ? ChildStates[stateMachine.DefaultState].State : default;

            file.AddAsset(this);
        }
Esempio n. 40
0
 public void LoadFrom(Stream stream)
 {
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Mesh = new PPtr<Mesh>(stream, file);
 }
Esempio n. 41
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     lengthInSec = reader.ReadSingle();
     startDelay = reader.ReadSingle();
     speed = reader.ReadSingle();
     randomSeed = reader.ReadUInt32();
     looping = reader.ReadBoolean();
     prewarm = reader.ReadBoolean();
     playOnAwake = reader.ReadBoolean();
     moveWithTransform = reader.ReadBoolean();
     InitialModule = new InitialModule(stream);
     ShapeModule = new ShapeModule(file, stream);
     EmissionModule = new EmissionModule(stream);
     SizeModule = new SizeModule(stream);
     RotationModule = new RotationModule(stream);
     ColorModule = new ColorModule(stream);
     UVModule = new UVModule(stream);
     VelocityModule = new VelocityModule(stream);
     ForceModule = new ForceModule(stream);
     ExternalForcesModule = new ExternalForcesModule(stream);
     ClampVelocityModule = new ClampVelocityModule(stream);
     SizeBySpeedModule = new SizeBySpeedModule(stream);
     RotationBySpeedModule = new RotationBySpeedModule(stream);
     ColorBySpeedModule = new ColorBySpeedModule(stream);
     CollisionModule = new CollisionModule(file, stream);
     SubModule = new SubModule(file, stream);
 }
Esempio n. 42
0
        public void LoadFrom(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            m_GameObject = new PPtr<GameObject>(stream, file);
            m_Enabled = reader.ReadBoolean();
            m_CastShadows = reader.ReadBoolean();
            m_ReceiveShadows = reader.ReadBoolean();
            m_LightmapIndex = reader.ReadByte();
            m_LightmapTilingOffset = reader.ReadVector4();

            int numMaterials = reader.ReadInt32();
            m_Materials = new List<PPtr<Material>>(numMaterials);
            for (int i = 0; i < numMaterials; i++)
            {
                m_Materials.Add(new PPtr<Material>(stream, file));
            }

            int numSubsetIndices = reader.ReadInt32();
            m_SubsetIndices = reader.ReadUInt32Array(numSubsetIndices);

            m_StaticBatchRoot = new PPtr<Transform>(stream, file);
            m_UseLightProbes = reader.ReadBoolean();
            reader.ReadBytes(3);
            m_LightProbeAnchor = new PPtr<Transform>(stream, file);
            m_SortingLayerID = reader.ReadUInt32();
            m_SortingOrder = reader.ReadInt16();
            reader.ReadBytes(2);
        }
Esempio n. 43
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     enabled = reader.ReadBoolean();
     reader.ReadBytes(3);
     subEmitterBirth = new PPtr<ParticleSystem>(stream, file);
     subEmitterBirth1 = new PPtr<ParticleSystem>(stream, file);
     subEmitterCollision = new PPtr<ParticleSystem>(stream, file);
     subEmitterCollision1 = new PPtr<ParticleSystem>(stream, file);
     subEmitterDeath = new PPtr<ParticleSystem>(stream, file);
     subEmitterDeath1 = new PPtr<ParticleSystem>(stream, file);
 }
Esempio n. 44
0
 public void LoadFrom(Stream stream)
 {
     long start = stream.Position;
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadBoolean();
     m_Emit = reader.ReadBoolean();
     reader.ReadBytes(2);
     minSize = reader.ReadSingle();
     maxSize = reader.ReadSingle();
     minEnergy = reader.ReadSingle();
     maxEnergy = reader.ReadSingle();
     minEmission = reader.ReadSingle();
     maxEmission = reader.ReadSingle();
     worldVelocity = reader.ReadVector3();
     localVelocity = reader.ReadVector3();
     rndVelocity = reader.ReadVector3();
     emitterVelocityScale = reader.ReadSingle();
     tangentVelocity = reader.ReadVector3();
     angularVelocity = reader.ReadSingle();
     rndAngularVelocity = reader.ReadSingle();
     rndRotation = reader.ReadBoolean();
     Simulate_in_Worldspace = reader.ReadBoolean();
     m_OneShot = reader.ReadBoolean();
     reader.ReadByte();
     m_Ellipsoid = reader.ReadVector3();
     m_MinEmitterRange = reader.ReadSingle();
 }
Esempio n. 45
0
 public AssetInfo(AssetCabinet file, Stream stream)
 {
     this.file = file;
     BinaryReader reader = new BinaryReader(stream);
     preloadIndex = reader.ReadInt32();
     preloadSize = reader.ReadInt32();
     PPtr<Object> objPtr = new PPtr<Object>(stream);
     if (objPtr.m_FileID == 0 && objPtr.m_PathID != 0)
     {
         Component comp = file.FindComponent(objPtr.m_PathID, false);
         if (comp == null)
         {
             comp = new NotLoaded(file, objPtr.m_PathID, 0, 0);
         }
         asset = new PPtr<Object>(comp);
     }
     else
     {
         asset = objPtr;
     }
 }
Esempio n. 46
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     m_Enabled = reader.ReadByte();
     reader.ReadBytes(3);
     m_Type = reader.ReadInt32();
     m_Color = reader.ReadColor4();
     m_Intensity = reader.ReadSingle();
     m_Range = reader.ReadSingle();
     m_SpotAngle = reader.ReadSingle();
     m_CookieSize = reader.ReadSingle();
     m_Shadows = new ShadowSettings(stream);
     m_Cookie = new PPtr<Texture2D>(stream, file);
     m_DrawHalo = reader.ReadBoolean();
     m_ActuallyLightmapped = reader.ReadBoolean();
     reader.ReadBytes(2);
     m_Flare = new PPtr<Flare>(stream, file);
     m_RenderMode = reader.ReadInt32();
     m_CullingMask = new BitField(stream);
     m_Lightmapping = reader.ReadInt32();
 }
Esempio n. 47
0
 public void Add(PPtr pptr)
 {
     this.references.Add(pptr);
 }
Esempio n. 48
0
        protected virtual void ReadNode(TypeNode typeNode, ArchiveBinaryReader reader, ObjectArchive archive, Stream output, FeatureInfo data)
        {
            Stream src = reader.BaseStream;

            switch (typeNode.TypeFlag)
            {
            case "bool":
            case "SInt8":
            case "char":
            case "UInt8":
            case "short":
            case "SInt16":
            case "unsigned short":
            case "UInt16":
            case "int":
            case "SInt32":
            case "unsigned int":
            case "UInt32":
            case "Type*":
            case "long long":
            case "SInt64":
            case "unsigned long long":
            case "UInt64":
            case "float":
            case "double":
            case "Quaternionf":
            case "float4":
            case "Vector4f":
            case "float3":
            case "Vector3f":
            case "float2":
            case "Vector2f":
            case "ColorRGBA":
            case "Matrix4x4f":
            case "Hash128":
            {
                this.CopyTo(src, output, typeNode.Size);
                break;
            }

            case "string":
            {
                if ((typeNode.Depth == 1 || (typeNode.Depth == 2 && typeNode.Root.TypeID == TypeID.Shader)) && typeNode.FieldName.Equals("m_Name"))
                {
                    var position = reader.BaseStream.Position;
                    data.Name = reader.ReadString();
                    reader.BaseStream.Position = position;
                }

                int size = reader.ReadInt32();
                if (size > 0)
                {
                    this.CopyTo(src, output, size);
                }
                reader.Align(4);
                break;
            }

            case "Array":
            {
                var valueTypeNode = typeNode.Children[1];
                var size          = reader.ReadInt32();
                if (size <= 0)
                {
                    break;
                }

                this.ReadArrayNode(valueTypeNode, size, reader, archive, output, data);
                break;
            }

            case "TypelessData":
            {
                var size = reader.ReadInt32();
                if (size > 0)
                {
                    this.CopyTo(src, output, size);
                }
                break;
            }

            case "PPtr":
            {
                var fileID = reader.ReadInt32();
                var pathID = reader.ReadInt64();
                var pptr   = new PPtr(fileID, pathID, typeNode.TypeName);
                data.Add(pptr);
                break;
            }

            case "StreamedResource":
            {
                var source           = reader.ReadString();
                var offset           = reader.ReadUInt64();
                var size             = reader.ReadUInt64();
                var streamedResource = new StreamedResource(source, offset, size);
                data.Resources = streamedResource;

                if (size <= 0)
                {
                    break;
                }

                using (Stream dataStream = archive.GetResourceStream(streamedResource))
                {
                    if (dataStream == null)
                    {
                        break;
                    }

                    byte[] buffer = ArchiveUtil.HashBytes(dataStream);
                    output.Write(buffer, 0, buffer.Length);
                }
                break;
            }

            default:
            {
                foreach (TypeNode childNode in typeNode.Children)
                {
                    ReadNode(childNode, reader, archive, output, data);
                }
                break;
            }
            }

            if (typeNode.IsAlign)
            {
                reader.Align(4);
            }
        }
Esempio n. 49
0
 public PPtrKeyframe(float time, PPtr <Object> script)
 {
     Time   = time;
     Script = script;
 }
Esempio n. 50
0
 public void LoadFrom(Stream stream)
 {
     BinaryReader reader = new BinaryReader(stream);
     m_GameObject = new PPtr<GameObject>(stream, file);
     Data = reader.ReadBytes(30);
 }
Esempio n. 51
0
 protected void SetDefaults()
 {
     m_Enabled = true;
     m_CastShadows = true;
     m_ReceiveShadows = true;
     m_LightmapIndex = 255;
     m_LightmapTilingOffset = new Vector4(1, 1, 0, 0);
     m_Materials = new List<PPtr<Material>>(1);
     m_SubsetIndices = new uint[0];
     m_StaticBatchRoot = new PPtr<Transform>((Component)null);
     m_LightProbeAnchor = new PPtr<Transform>((Component)null);
 }
Esempio n. 52
0
 public bool TryGet <T>([NotNull] PPtr <T> ptr, [CanBeNull] out T result)
     where T : Object
 {
     return(TryGet <T, T>(ptr, out result));
 }