예제 #1
0
        private IEnumerator ShowModelTask(string name, string motionName, bool motionLoop, string expressionName, Vector3 position, float duration)
        {
            L2DModel model = LoadModel(name);

            if (model == null)
            {
                yield break;
            }

            model.SetActivate(true);
            model.SetEyeBlinkEnabled(false);
            if (expressionName == "")
            {
                model.ClearExpression(true);
            }
            else
            {
                model.SetExpression(expressionName, true);
            }
            model.SetMotion(motionName, motionLoop, true);
            model.SetPosition(position);
            float startTime = Time.time;

            while (Time.time - (startTime + duration) < 0.0f)
            {
                float rate = (Time.time - startTime) / duration;
                model.SetAlpha(Mathf.Lerp(0.0f, 1.0f, rate));
                yield return(null);
            }
            model.SetAlpha(1.0f);
        }
예제 #2
0
        private Dictionary <string, L2DModel> _models = new Dictionary <string, L2DModel>(); // <모델정보명, 생성된 모델>

        public L2DModel LoadModel(string modelInfoName)
        {
            L2DModel model = null;

            if (_models.TryGetValue(modelInfoName, out model))
            {
                return(model);
            }

            string    filepath = Define.L2D._modelInfoRoot + "/" + modelInfoName;
            TextAsset infoText = Resources.Load <TextAsset>(filepath);

            if (infoText == null)
            {
                Debug.LogError("'" + modelInfoName + "' ModelInfo does not exist");
                return(null);
            }

            int          slotIdx = RegisterToSlot(modelInfoName);
            L2DModelInfo info    = JsonUtility.FromJson <L2DModelInfo>(infoText.text);

            model = new L2DModel();
            model.Initialize(info, slotIdx);
            model.SetActivate(false);

            _models.Add(modelInfoName, model);
            return(model);
        }
예제 #3
0
        private IEnumerator HideModelTask(string name, float duration)
        {
            L2DModel model = GetActiveModel(name);

            if (model == null)
            {
                Debug.LogError("Not exist activated model " + name);
                yield break;
            }

            float startTime = Time.time;

            while (Time.time - (startTime + duration) < 0.0f)
            {
                float rate = (Time.time - startTime) / duration;
                model.SetAlpha(Mathf.Lerp(1.0f, 0.0f, rate));
                yield return(null);
            }
            model.SetActivate(false);
        }