Пример #1
0
            protected virtual void DisplaySliderInfo(int id, bool readonly_name = false, bool readonly_interp = false, bool readonly_pos = false)
            {
                Animator           animator;
                AnimatorController controller;
                SerializedProperty slider_sp;
                LBSlider           slider;
                List <string>      param_names = new List <string>();
                int i;

                animator = ((Component)target).gameObject.GetComponent <Animator>();

                if (animator == null)
                {
                    return;
                }

                controller = (AnimatorController)animator.runtimeAnimatorController;

                if (controller == null || controller.parameters.Length == 0)
                {
                    return;
                }

                slider_sp = serializedObject.FindProperty("sliders");
                slider    = new LBSlider(slider_sp.GetArrayElementAtIndex(id));

                for (i = 0; i < controller.parameters.Length; i++)
                {
                    if (controller.parameters[i].type == AnimatorControllerParameterType.Float)
                    {
                        param_names.Add(controller.parameters[i].name);
                    }
                }

                // гемор: может быть использован парамтер с одним именем дважды!

                EditorGUI.BeginDisabledGroup(readonly_name);
                if (param_names.IndexOf(slider.Name) > 0 && param_names.IndexOf(slider.Name) < param_names.Count)
                {
                    slider.Name = param_names[EditorGUILayout.Popup("Parameter", param_names.IndexOf(slider.Name), param_names.ToArray())];
                }
                else
                {
                    slider.Name = param_names[EditorGUILayout.Popup("Animation", 0, param_names.ToArray())];
                }
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(readonly_interp);
                slider.InterpRate = EditorGUILayout.FloatField("Interpolation rate", slider.InterpRate);
                EditorGUI.EndDisabledGroup();

                EditorGUI.BeginDisabledGroup(readonly_pos);
                slider.Position = EditorGUILayout.Slider("Position", slider.Position, 0, 1);
                EditorGUI.EndDisabledGroup();

                slider.SetSerializedProperty(slider_sp.GetArrayElementAtIndex(id));
            }
Пример #2
0
            protected void AddNewSlider()
            {
                SerializedProperty sliders;
                LBSlider           slider;

                slider  = new LBSlider("noparam", 0);
                sliders = serializedObject.FindProperty("sliders");

                sliders.arraySize++;
                slider.SetSerializedProperty(sliders.GetArrayElementAtIndex(sliders.arraySize - 1));
            }