Exemple #1
0
    public void LoadFromStreamingAssets(String dir, String filename)
    {
        if (LAppDefine.DEBUG_LOG)
        {
            Debug.Log(dir + filename);
        }
        modelHomeDir = dir;
        var data = Live2DFramework.getPlatformManager().loadString(modelHomeDir + filename);

        Init(data);
    }
Exemple #2
0
    public void LoadAssets(string modelId, List <string> donotUnloadIds)
    {
        _donotUnloadIds = donotUnloadIds;
        if (_modelId != null)
        {
            UnloadAsset();
        }

        _modelId        = modelId;
        _expressionList = new List <string>();
        _motionList     = new List <string>();

        var data = Live2DFramework.GetPlatformManager().loadString(AssetLoader.GetLive2dModelJsonById(modelId));

        Init(data, modelId);
    }
Exemple #3
0
    private void Start()
    {
        if (path == "")
        {
            return;
        }

#if !UNITY_EDITOR
        LAppDefine.DEBUG_LOG       = false;
        LAppDefine.DEBUG_TOUCH_LOG = false;
#endif
        model = new LAppModel(this);


        Live2D.init();
        Live2DFramework.setPlatformManager(new PlatformManager());

        var filename = FileManager.getFilename(path);
        var dir      = FileManager.getDirName(path);
        model.LoadFromStreamingAssets(dir, filename);

        // model.loadTexture(2, "haru/haru_01.1024/texture_03.png");
    }
Exemple #4
0
 private void Awake()
 {
     Live2DFramework.SetPlatformManager(new Live2dPlatformManager());
 }
Exemple #5
0
 private void ClearL2D()
 {
     Live2DFramework.setPlatformManager(null);
     Live2D.dispose();
 }
Exemple #6
0
 private void InitializeL2D()
 {
     Live2D.init();
     Live2DFramework.setPlatformManager(new PlatformManager());
 }
 public LAppLive2DManager()
 {
     Live2D.init();
     Live2DFramework.setPlatformManager(new PlatformManager());
     models = new List <LAppModelProxy>();
 }
Exemple #8
0
    public void Initialize(L2DModelInfo modelInfo, int modelSlotIdx)
    {
        setUpdating(true);  // 모델 갱신중
        setInitialized(false);

        _IsActivate     = true;
        _modelHomeDir   = FileManager.getDirName(modelInfo._SettingFullPath);
        _modelRenderPos = new Vector3(modelSlotIdx * 5.0f, 60.0f, 0.0f);

        GameObject proxyObj = new GameObject(modelInfo._modelName);

        _proxy = proxyObj.AddComponent <L2DModelProxy>();
        _proxy.Initialize(this, modelInfo._planeSize, _modelRenderPos);

        string modelJson = Live2DFramework.getPlatformManager().loadString(modelInfo._SettingFullPath);

        _modelSetting = new ModelSettingJson(modelJson);
        startTimeMSec = UtSystem.getUserTimeMSec();
        _updatedOnce  = false;

        // Live2D Model
        if (_modelSetting.GetModelFile() != null)
        {
            loadModelData(_modelHomeDir + _modelSetting.GetModelFile());

            var len = _modelSetting.GetTextureNum();
            for (int i = 0; i < len; i++)
            {
                loadTexture(i, _modelHomeDir + _modelSetting.GetTextureFile(i));
            }
        }

        // 모션은 미리 읽지 않고 각 모션 재생 시도 시 읽어들임

        // Expression
        if (_modelSetting.GetExpressionNum() != 0)
        {
            var len = _modelSetting.GetExpressionNum();
            for (int i = 0; i < len; i++)
            {
                loadExpression(_modelSetting.GetExpressionName(i), _modelHomeDir + _modelSetting.GetExpressionFile(i));
            }
        }

        // Physics
        if (_modelSetting.GetPhysicsFile() != null)
        {
            loadPhysics(_modelHomeDir + _modelSetting.GetPhysicsFile());
        }

        // Pose
        if (_modelSetting.GetPoseFile() != null)
        {
            loadPose(_modelHomeDir + _modelSetting.GetPoseFile());
        }

        // 파라미터 초기값
        for (int i = 0; i < _modelSetting.GetInitParamNum(); i++)
        {
            string id    = _modelSetting.GetInitParamID(i);
            float  value = _modelSetting.GetInitParamValue(i);
            live2DModel.setParamFloat(id, value);
        }

        // 파츠
        for (int i = 0; i < _modelSetting.GetInitPartsVisibleNum(); i++)
        {
            string id    = _modelSetting.GetInitPartsVisibleID(i);
            float  value = _modelSetting.GetInitPartsVisibleValue(i);
            live2DModel.setPartsOpacity(id, value);
        }

        // 눈 자동깜빡임
        eyeBlink = new L2DEyeBlink();

        // 레이아웃. 적용 순서에 따라 결과 달라짐에 주의
        getModelMatrix().multScale(modelInfo._layout._scale, modelInfo._layout._scale);
        getModelMatrix().setY(modelInfo._layout._y);

        setUpdating(false); // 갱신상태 완료
        setInitialized(true);
    }
Exemple #9
0
    public void UnloadAsset()
    {
        if (CanUnload() == false)
        {
            return;
        }

        _baseDir = AssetLoader.GetLive2dDirById(_modelId) + "/";

        IPlatformManager pm = Live2DFramework.GetPlatformManager();

        pm.UnloadBytes(AssetLoader.GetLive2dModelJsonById(_modelId));

        // Live2D Model
        if (modelSetting.GetModelFile() != null)
        {
            pm.UnloadBytes(_baseDir + modelSetting.GetModelFile());

            var len = modelSetting.GetTextureNum();
            for (int i = 0; i < len; i++)
            {
                pm.UnloadTexture(_baseDir + modelSetting.GetTextureFile(i));
            }
        }

        // Expression
        if (modelSetting.GetExpressionNum() != 0)
        {
            var len = modelSetting.GetExpressionNum();
            for (int i = 0; i < len; i++)
            {
                pm.UnloadBytes(_baseDir + modelSetting.GetExpressionFile(i));
            }
        }

        // Physics
        if (modelSetting.GetPhysicsFile() != null)
        {
            pm.UnloadBytes(_baseDir + modelSetting.GetPhysicsFile());
        }

        // Pose
        if (modelSetting.GetPoseFile() != null)
        {
            pm.UnloadBytes(_baseDir + modelSetting.GetPoseFile());
        }


        string[] motionGroup = modelSetting.GetMotionGroupNames();

        for (int i = 0; i < motionGroup.Length; i++)
        {
            int num = modelSetting.GetMotionNum(motionGroup[i]);
            if (num != 0)
            {
                for (int j = 0; j < num; j++)
                {
                    pm.UnloadBytes(_baseDir + modelSetting.GetMotionFile(motionGroup[i], j));
                }
            }
        }

        _modelId = null;
    }
Exemple #10
0
    public static bool HasResource(string modelId)
    {
        string data = Live2DFramework.GetPlatformManager().loadString(AssetLoader.GetLive2dModelJsonById(modelId));

        return(!string.IsNullOrEmpty(data));
    }