private void Start()
        {
            using (var reader = new StringReader(m_iniContents))
            {
                var builder = new BlobBuilder(Allocator.Temp);
                BlobAssetReference <IniFile> configReference;

                try
                {
                    ref IniFile root = ref builder.ConstructRoot <IniFile>();

                    builder.AllocateString(ref root.Name, m_fileName);

                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] pairStr = line.Split('=');
                        if (pairStr.Length != 2 || string.IsNullOrEmpty(pairStr[0]))
                        {
                            continue;
                        }

                        switch (pairStr[0])
                        {
                        case "foo":
                            int.TryParse(pairStr[1], out root.Foo);
                            break;

                        case "bar":
                            if (root.Bar.Length != 0)
                            {
                                continue;
                            }
                            builder.AllocateString(ref root.Bar, pairStr[1]);
                            break;

                        case "baz":
                            float.TryParse(pairStr[1], out root.Baz);
                            break;

                        case "qux":
                            Enum.TryParse(pairStr[1], true, out root.Qux);
                            break;
                        }
                    }

                    configReference = builder.CreateBlobAssetReference <IniFile>(Allocator.Persistent);
                }
Ejemplo n.º 2
0
 protected override void Build(ref VariablesTestNode data, BlobBuilder builder, ITreeNode <INodeDataBuilder>[] builders)
 {
     LongVariable.Allocate(ref builder, ref data.LongVariable);
     builder.AllocateString(ref data.String, String);
     builder.AllocateArray(ref data.IntArray, IntArray);
     DestVariable.Allocate(ref builder, ref data.DestVariable);
     SrcVariable.Allocate(ref builder, ref data.SrcVariable);
 }
Ejemplo n.º 3
0
 protected override unsafe void Build(ref VariablesTestNode data, BlobBuilder builder, ITreeNode <INodeDataBuilder>[] tree)
 {
     LongReader.Allocate(ref builder, ref data.LongReader, this, tree);
     builder.AllocateString(ref data.String, String);
     builder.AllocateArray(ref data.IntArray, IntArray);
     LongWriter.Allocate(ref builder, ref data.LongWriter, this, tree);
     SingleReader.Allocate(ref builder, ref data.SingleReader, this, tree);
     data.Long = LongValue;
     SingleReaderAndWriter.Allocate(ref builder, ref data.SingleReaderAndWriter, this, tree);
 }
Ejemplo n.º 4
0
    // Construct Shared Array For Serveral Entities
    protected override void OnUpdate()
    {
        // 读取数据并存储在 BlobAsset 中
        gmBlobRefs = new List <BlobAssetReference <GroundMotionBlobAsset> >();
        // 获得所有可选 GroundMotion 的名字
        var gms = GmDataReader.GroundMotionFolders(groundMotionPath);

        foreach (var item in gms)
        {
            //FIXME: Debug 运行了两次,表示读取了两次数据? 可能有问题代码
            //Debug.Log(item);
            if (!GetData(item))
            {
                break;
            }

            // 创建 BlobBuilder,赋值 gmArray 和 gmName
            BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp);

            // Blob 声明资产类型
            ref GroundMotionBlobAsset       groundMotionBlobAsset = ref blobBuilder.ConstructRoot <GroundMotionBlobAsset>();
            BlobBuilderArray <GroundMotion> gmArray = blobBuilder.Allocate(ref groundMotionBlobAsset.gmArray, acc.Count);

            // 存储加速度数据为 BlobArray
            // TODO: 也许有新的数据转换方式从 List<Vector3> 到 BlobBuilderArray<GroundMotion>
            for (int i = 0; i < acc.Count; ++i)
            {
                gmArray[i] = new GroundMotion {
                    acceleration = new float3(acc[i])
                };
            }

            // 存储相应地震名字为 BlobString
            blobBuilder.AllocateString(ref groundMotionBlobAsset.gmName, item);

            // 声明 Blob 资产引用
            BlobAssetReference <GroundMotionBlobAsset> groundMotionBlobAssetReference =
                blobBuilder.CreateBlobAssetReference <GroundMotionBlobAsset>(Allocator.Persistent);

            gmBlobRefs.Add(groundMotionBlobAssetReference);
            // 释放 BlobBuilder
            blobBuilder.Dispose();
        }
Ejemplo n.º 5
0
#pragma warning restore 0649

        public CharacterState BuildState(ref BlobBuilder builder,
                                         CharacterControllerBuildParams builderParams)
        {
            var state = new CharacterState {
                Animation = AnimationClipPlayable.Create(builderParams.Graph, Animation)
            };

            builder.AllocateString(ref state.Name, _name);
            builder.Construct(ref state.Frames, BuildFrames());
            builder.Construct(ref state.Hitboxes, BuildHitboxes(ref builder));

            var transitions = new List <CharacterStateTransition>();

            foreach (var transition in _transitions)
            {
                if (!transition.Enabled)
                {
                    continue;
                }
                transitions.Add(transition.ToStateTransition(ref builder, builderParams.StateMap));
            }
            builder.Construct(ref state.Transitions, transitions.ToArray());
            return(state);
        }
Ejemplo n.º 6
0
 public override void Build(BlobBuilder builder, ref BlobString data)
 {
     builder.AllocateString(ref data, Value);
 }