public Camera getCamera(AMITarget itarget)
        {
            if (itarget.isMeta)
            {
                if (!string.IsNullOrEmpty(_cameraPath))
                {
                    Transform t = itarget.GetCache(_cameraPath);
                    if (t)
                    {
                        return(t.GetComponent <Camera>());
                    }
                    else
                    {
                        t = AMUtil.GetTarget(itarget.root, _cameraPath);
                        itarget.SetCache(_cameraPath, t);
                        if (t)
                        {
                            return(t.GetComponent <Camera>());
                        }
                    }
                }

                return(null);
            }
            else
            {
                return(_camera);
            }
        }
示例#2
0
        /// <summary>
        /// Gets the target relative to animator's hierarchy if we are referencing via AnimatorMeta
        /// </summary>
        public UnityEngine.Object GetTarget(AMITarget target)
        {
            UnityEngine.Object ret = null;

            if (target.isMeta)
            {
                Transform tgt = target.GetCache(_targetPath);
                if (tgt)
                {
                    ret = GetSerializeObject(tgt.gameObject);
                }
                else
                {
                    tgt = AMUtil.GetTarget(target.root, _targetPath);
                    target.SetCache(_targetPath, tgt);
                    if (tgt)
                    {
                        ret = GetSerializeObject(tgt.gameObject);
                    }
                }
            }
            else
            {
                ret = GetSerializeObject(null);
            }

            return(ret);
        }
示例#3
0
        public override void maintainKey(AMITarget itarget, UnityEngine.Object targetObj)
        {
            if (itarget.isMeta)
            {
                if (string.IsNullOrEmpty(targetPath))
                {
                    if (target)
                    {
                        targetPath = AMUtil.GetPath(itarget.root, target);
                        itarget.SetCache(targetPath, target);
                    }
                }

                target = null;
            }
            else
            {
                if (!target)
                {
                    if (!string.IsNullOrEmpty(targetPath))
                    {
                        target = itarget.GetCache(targetPath);
                        if (!target)
                        {
                            target = AMUtil.GetTarget(itarget.root, targetPath);
                        }
                    }
                }

                targetPath = "";
            }
        }
        public override void maintainKey(AMITarget itarget, UnityEngine.Object targetObj)
        {
            if (itarget.isMeta)
            {
                if (string.IsNullOrEmpty(_cameraPath))
                {
                    if (_camera)
                    {
                        _cameraPath = AMUtil.GetPath(itarget.root, _camera);
                        itarget.SetCache(_cameraPath, _camera.transform);
                    }
                }

                if (string.IsNullOrEmpty(_cameraEndPath))
                {
                    if (_cameraEnd)
                    {
                        _cameraEndPath = AMUtil.GetPath(itarget.root, _cameraEnd);
                        itarget.SetCache(_cameraEndPath, _cameraEnd.transform);
                    }
                }

                _camera    = null;
                _cameraEnd = null;
            }
            else
            {
                if (!_camera)
                {
                    if (!string.IsNullOrEmpty(_cameraPath))
                    {
                        Transform t = itarget.GetCache(_cameraPath);
                        if (!t)
                        {
                            t = AMUtil.GetTarget(itarget.root, _cameraPath);
                        }
                        _camera = t ? t.GetComponent <Camera>() : null;
                    }
                }

                if (!_cameraEnd)
                {
                    if (!string.IsNullOrEmpty(_cameraEndPath))
                    {
                        Transform t = itarget.GetCache(_cameraEndPath);
                        if (!t)
                        {
                            t = AMUtil.GetTarget(itarget.root, _cameraEndPath);
                        }
                        _cameraEnd = t ? t.GetComponent <Camera>() : null;
                    }
                }

                _cameraPath    = "";
                _cameraEndPath = "";
            }
        }
示例#5
0
        /// <summary>
        /// attempt to generate the missing targets
        /// </summary>
        void AMITarget.GenerateMissingTargets(string[] missingPaths)
        {
            if (missingPaths != null && missingPaths.Length > 0)
            {
                for (int i = 0; i < missingPaths.Length; i++)
                {
                    AMUtil.CreateTarget(transform, missingPaths[i]);
                }

                //fill necessary components per track and key
                foreach (AMTakeData take in _takes)
                {
                    foreach (AMTrack track in take.trackValues)
                    {
                        Transform t = AMUtil.GetTarget(transform, track.targetPath);

                        System.Type compType = track.GetRequiredComponent();
                        if (compType != null)
                        {
                            Component comp = t.gameObject.GetComponent(compType);
                            if (comp == null)
                            {
                                t.gameObject.AddComponent(compType);
                            }
                        }

                        foreach (AMKey key in track.keys)
                        {
                            compType = key.GetRequiredComponent();
                            if (compType != null)
                            {
                                Component comp = t.gameObject.GetComponent(compType);
                                if (comp == null)
                                {
                                    t.gameObject.AddComponent(compType);
                                }
                            }
                        }
                    }
                }

                if (mCache != null)
                {
                    mCache.Clear();
                }
            }
        }
示例#6
0
        public virtual void maintainTrack(AMITarget itarget)
        {
            Object obj = null;

            //fix the target info
            if (itarget.isMeta)
            {
                if (string.IsNullOrEmpty(_targetPath))
                {
                    obj = GetSerializeObject(null);
                    if (obj)
                    {
                        _targetPath = AMUtil.GetPath(itarget.root, obj);
                        itarget.SetCache(_targetPath, AMUtil.GetTransform(obj));
                    }
                }
                SetSerializeObject(null);
            }
            else
            {
                obj = GetSerializeObject(null);
                if (obj == null)
                {
                    if (!string.IsNullOrEmpty(_targetPath))
                    {
                        Transform tgt = itarget.GetCache(_targetPath);
                        if (tgt == null)
                        {
                            tgt = AMUtil.GetTarget(itarget.root, _targetPath);
                        }
                        if (tgt)
                        {
                            obj = GetSerializeObject(tgt.gameObject);
                        }
                        SetSerializeObject(obj);
                    }
                }
                _targetPath = "";
            }

            //maintain keys
            foreach (AMKey key in keys)
            {
                key.maintainKey(itarget, obj);
            }
        }
示例#7
0
        public Transform GetTarget(AMITarget itarget)
        {
            Transform ret = null;

            if (itarget.isMeta)
            {
                if (!string.IsNullOrEmpty(targetPath))
                {
                    ret = itarget.GetCache(targetPath);
                    if (ret == null)
                    {
                        ret = AMUtil.GetTarget(itarget.root, targetPath);
                        itarget.SetCache(targetPath, ret);
                    }
                }
            }
            else
            {
                ret = target;
            }
            return(ret);
        }