Beispiel #1
0
        private void Start()
        {
            //エディタの場合はStreamingAssets以下で代用(無ければ無いでOK)
            string dirPath = Application.isEditor
                ? Path.Combine(
                Application.streamingAssetsPath, "Motions")
                : Path.Combine(
                Path.GetDirectoryName(Application.dataPath),
                "Motions"
                );

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            var importer = new MotionImporter();

            foreach (var filePath in Directory.GetFiles(dirPath).Where(p => Path.GetExtension(p) == ".vmm_motion"))
            {
                try
                {
                    var motion = importer.LoadSerializedMotion(File.ReadAllText(filePath));
                    if (motion == null)
                    {
                        continue;
                    }
                    var motionName = Path.GetFileNameWithoutExtension(filePath);
                    var flags      = motion.LoadMuscleFlags();
                    SerializeMuscleNameMapper.MaskUsedMuscleFlags(flags, MuscleFlagMaskStyle.OnlyUpperBody);
                    _clips[motionName.ToLower()] = new CustomMotionItem(
                        motionName,
                        flags,
                        importer.Deserialize(motion)
                        );
                }
                catch (Exception ex)
                {
                    LogOutput.Instance.Write(ex);
                }
            }
        }
Beispiel #2
0
 private void Awake()
 {
     Target = (MotionImporter)target;
 }