コード例 #1
0
        void IDirectable.SceneGUI(bool selected)
        {
            if (!selected || actor == null || !isValid)
            {
                return;
            }

            if (hasParameters)
            {
                for (var i = 0; i < animationData.animatedParameters.Count; i++)
                {
                    var animParam = animationData.animatedParameters[i];
                    if (!animParam.isValid || animParam.animatedType != typeof(Vector3))
                    {
                        continue;
                    }
                    var         m          = animParam.GetMemberInfo();
                    Attribute[] attributes = null;
                    if (!paramsAttributes.TryGetValue(m, out attributes))
                    {
                        attributes          = (Attribute[])m.GetCustomAttributes(false);
                        paramsAttributes[m] = attributes;
                    }

                    ITransformableHelperParameter link = null;
                    var animAtt = attributes.FirstOrDefault(a => a is AnimatableParameterAttribute) as AnimatableParameterAttribute;
                    if (animAtt != null)                      //only in case parameter has been added manualy. Probably never.
                    {
                        if (!string.IsNullOrEmpty(animAtt.link))
                        {
                            try { link = (GetType().GetField(animAtt.link).GetValue(this) as ITransformableHelperParameter); }
                            catch (Exception exc) { Debug.LogError(exc.Message); }
                        }
                    }

                    if (link == null || link.useAnimation)
                    {
                        var space = link != null? link.space : defaultTransformSpace;

                        var posHandleAtt = attributes.FirstOrDefault(a => a is PositionHandleAttribute) as PositionHandleAttribute;
                        if (posHandleAtt != null)
                        {
                            DoParameterPositionHandle(animParam, space);
                        }

                        var trajAtt = attributes.FirstOrDefault(a => a is ShowTrajectoryAttribute) as ShowTrajectoryAttribute;
                        if (trajAtt != null && animParam.enabled)
                        {
                            CurveEditor3D.Draw3DCurve(animParam, this, GetSpaceTransform(space), length / 2, length);
                        }
                    }
                }
            }

            OnSceneGUI();
        }
コード例 #2
0
        protected override void OnSceneGUI()
        {
            if (actor == null || actor.Equals(null) || !showCurves || !isActive || animationData == null || !animationData.isValid)
            {
                return;
            }

            for (var i = 0; i < animationData.animatedParameters.Count; i++)
            {
                var animParam = animationData.animatedParameters[i];
                if (animParam.isValid && animParam.parameterName == "localPosition")
                {
                    var transform = animParam.ResolvedMemberObject() as Transform;
                    if (transform != null)
                    {
                        var context = transform.parent != null ? transform.parent : this.GetSpaceTransform(TransformSpace.CutsceneSpace);
                        CurveEditor3D.Draw3DCurve(animParam, this, context, root.currentTime);
                    }
                }
            }
        }
コード例 #3
0
        protected override void OnSceneGUI()
        {
            if (targetShot == null)
            {
                return;
            }

            UnityEditor.Handles.BeginGUI();
            GUI.backgroundColor = lookThrough ? Color.red : Color.white;
            if (targetShot != null && GUI.Button(new Rect(5, 5, 200, 20), lookThrough ? "Exit Look Through Camera" : "Look Through Camera"))
            {
                lookThrough = !lookThrough;
            }
            GUI.backgroundColor = Color.white;
            UnityEditor.Handles.EndGUI();

            var sc = UnityEditor.SceneView.lastActiveSceneView;

            if (lookThrough && sc != null)
            {
                if (root.currentTime == lastSampleTime)
                {
                    if (sc.camera.transform.position != lastPos || sc.camera.transform.rotation != lastRot)
                    {
                        UnityEditor.Undo.RecordObject(targetShot.transform, "Shot Change");
                        targetShot.position = sc.camera.transform.position;
                        targetShot.rotation = sc.camera.transform.rotation;
                        UnityEditor.EditorUtility.SetDirty(targetShot.gameObject);
                    }

                    lastPos = sc.camera.transform.position;
                    lastRot = sc.camera.transform.rotation;
                }
                else
                {
                    if (sc.camera.transform.position != targetShot.position || sc.camera.transform.rotation != targetShot.rotation)
                    {
                        sc.rotation = targetShot.rotation;
                        sc.pivot    = targetShot.position + (targetShot.transform.forward * 5);
                        sc.size     = 5;
                    }
                }

                lastSampleTime = root.currentTime;
            }

            //show other handles only if not in look through mode
            if (!lookThrough)
            {
                var posParam = GetParameter((CameraShot x) => x.position);
                if (posParam.enabled)
                {
                    CurveEditor3D.Draw3DCurve(posParam, this, targetShot.transform.parent, length / 2, length);
                }

                targetShot.OnSceneGUI();

                /*
                 *              //controls for focal point and focal range.
                 *              UnityEditor.EditorGUI.BeginChangeCheck();
                 *              var pos = targetShot.transform.position;
                 *              var focalPos = targetShot.transform.position + (targetShot.transform.forward * focalPoint);
                 *              var range = focalRange;
                 *              focalPos = UnityEditor.Handles.FreeMoveHandle(focalPos, Quaternion.identity, 0.2f, Vector3.zero, UnityEditor.Handles.CircleCap);
                 *              UnityEditor.Handles.DrawLine(targetShot.transform.position, focalPos);
                 *              UnityEditor.Handles.color = Color.green;
                 *              var rangeMin = targetShot.transform.position + (targetShot.transform.forward * (focalPoint - range));
                 *              var rangeMax = targetShot.transform.position + (targetShot.transform.forward * (focalPoint + range));
                 *              UnityEditor.Handles.DrawLine(rangeMin, rangeMax);
                 *              range = UnityEditor.Handles.ScaleValueHandle(range, rangeMin, Quaternion.identity, 0.5f, UnityEditor.Handles.DotCap, 0);
                 *              range = UnityEditor.Handles.ScaleValueHandle(range, rangeMax, Quaternion.identity, 0.5f, UnityEditor.Handles.DotCap, 0);
                 *              UnityEditor.Handles.color = Color.white;
                 *              pos = UnityEditor.Handles.PositionHandle(pos, Quaternion.identity);
                 *              if (UnityEditor.EditorGUI.EndChangeCheck()){
                 *                  UnityEditor.Undo.RecordObject(targetShot.transform, "Camera Change");
                 *                  UnityEditor.Undo.RecordObject(targetShot, "Camera Change");
                 *                  targetShot.transform.LookAt(focalPos);
                 *                  focalPoint = Vector3.Distance(targetShot.transform.position, focalPos);
                 *                  focalRange = range;
                 *                  targetShot.transform.position = pos;
                 *              }
                 */
            }
        }