コード例 #1
0
        /***********************************************
        *  override
        ***********************************************/

        public override void OnTargetChange()
        {
            if (target == null)
            {
                PSLogger.Log("Target is null");
                return;
            }

            EditorCurveBinding[] bindings = AnimationUtility.GetAnimatableBindings(target, target);
            bindingList.Clear();

            for (int i = 0; i < this.propertyMuscleName.Length; i++)
            {
                for (int j = 0; j < bindings.Length; j++)
                {
                    EditorCurveBinding binding = bindings [j];
                    if (binding.type.Equals(typeof(Animator)) && binding.propertyName == this.propertyMuscleName [i])
                    {
                        bindingList.Add(binding);
                        break;
                    }
                }
            }
            curveBindings = bindingList.ToArray();
        }
コード例 #2
0
        public void WriteMuscleValue(int index, float value)
        {
            if (curveBindings == null)
            {
                OnTargetChange();
            }

            if (clip == null || curveBindings == null)
            {
                PSLogger.Error("Clip or curveBindings is null");
                return;
            }

            if (index >= curveBindings.Length)
            {
                PSLogger.Error("Array index is out of range");
                return;
            }

            Undo.RecordObject(clip, clip.name);

            if (muscleToggle [index])
            {
                this.SetEditorCurve(curveBindings [index], value);
            }
            else
            {
                AnimationUtility.SetEditorCurve(clip, curveBindings [index], null);
            }

            resample = true;
        }
コード例 #3
0
        public void WriteAllMuscleValue()
        {
            if (curveBindings == null)
            {
                OnTargetChange();
            }

            if (clip == null || curveBindings == null)
            {
                PSLogger.Error("Clip or curveBindings is null");
                return;
            }

            if (this.propertyMuscleName.Length > curveBindings.Length)
            {
                PSLogger.Error("CurveBindings length and propertyMuscleName length are not equal");
                return;
            }

            Undo.RecordObject(clip, clip.name);

            for (int i = 0, len = this.propertyMuscleName.Length; i < len; i++)
            {
                if (muscleToggle [i])
                {
                    this.SetEditorCurve(curveBindings [i], muscleValue [i]);
                }
                else
                {
                    AnimationUtility.SetEditorCurve(clip, curveBindings [i], null);
                }
            }

            resample = true;
        }
コード例 #4
0
        public override void OnUpdateValue()
        {
            if (target == null || clip == null)
            {
                PSLogger.Log("Target or clip is null");
                return;
            }

            this.muscleToggle = new bool[this.muscleCount];
            this.muscleValue  = new float[this.muscleCount];
            rootValue         = new float[PSMuscleDefine.rootProperty.Length];
            rootToggle        = new bool[PSMuscleDefine.rootProperty.Length];
            rootT             = false;
            rootQ             = false;

            foreach (EditorCurveBinding binding in AnimationUtility.GetCurveBindings(clip))
            {
                if (!binding.type.Equals(typeof(Animator)))
                {
                    continue;
                }
                //Debug.Log(binding.propertyName);
                for (int i = 0, len = PSMuscleDefine.rootProperty.Length; i < len; i++)
                {
                    if (binding.propertyName == PSMuscleDefine.rootProperty [i])
                    {
                        AnimationUtility.GetFloatValue(target, binding, out rootValue [i]);
                        rootToggle [i] = true;
                        if (i < 3)
                        {
                            rootT = true;
                        }
                        else
                        {
                            rootQ = true;
                        }
                        break;
                    }
                }

                for (int i = 0, len = this.propertyMuscleName.Length; i < len; i++)
                {
                    if (binding.propertyName == this.propertyMuscleName [i])
                    {
                        AnimationUtility.GetFloatValue(target, binding, out muscleValue [i]);
                        muscleToggle [i] = true;
                        break;
                    }
                }
            }
        }