Example #1
0
        private void OnDrawParameter(Rect rect, int index, bool active, bool focused)
        {
            var parameter = TreeAsset.Parameters[index];

            rect.height = VariantUtils.FieldHeight;
            rect.y     += 2;

            VariantUtils.DrawParameter(rect, parameter.Value);
        }
        private void GenericParameterDrawer(Rect rect, SerializedProperty element, GUIContent label, int index, bool selected, bool focused)
        {
            var param = element.GetAs <Variant>();

            if (param != null)
            {
                VariantUtils.DrawParameter(rect, param);
            }
            else
            {
                GUI.Label(rect, "Unable to render as Variant!");
            }
        }
        private void ParameterDraw(Rect rect, SerializedProperty element, GUIContent label, int index, bool selected, bool focused)
        {
            var param = element.GetAs <Framework.Parameter>();

            if (param != null)
            {
                VariantUtils.DrawParameter(rect, param.Value);
            }
            else
            {
                GUI.Label(rect, "Unable to render as Parameter!");
            }
        }
        void HandleBindValue(Rect rect, ParamBinding binding)
        {
            if (binding == null)
            {
                return;
            }

            var fieldRect = rect;


            fieldRect.y     += 2;
            fieldRect.height = EditorGUIUtility.singleLineHeight;

            VariantUtils.DrawParameter(fieldRect, binding.DefaultValue, false);
        }
Example #5
0
        private void OnDrawParameter(Rect rect, int index, bool active, bool focused)
        {
            var parameter = Node.Inputs[index];

            if (index == 0)
            {
                FirstPos = rect.y;
            }

            Positions[index] = rect.y - FirstPos;

            rect.height = VariantUtils.FieldHeight;
            rect.y     += 2;

            VariantUtils.DrawParameter(rect, parameter.Input);
        }
Example #6
0
    private void OnDrawParameter(Rect rect, int index, bool active, bool focused)
    {
        var parameter = Parameters[index];

        if (index == 0)
        {
            FirstPos = rect.y;
        }

        Positions.Resize(index + 1);
        Positions[index] = rect.y - FirstPos;

        rect.height = VariantUtils.FieldHeight;
        rect.y     += 2;

        VariantUtils.DrawParameter(rect, parameter.Value);
    }
        protected override void DrawContent()
        {
            if (Node.Anim)
            {
                GUI.Box(drawRect, GUIContent.none, EditorStyles.helpBox);

                var controller = AssetDatabase.LoadAssetAtPath <AnimatorController>(AssetDatabase.GetAssetPath(Node.Anim));
                if (controller == null)
                {
                    Debug.LogErrorFormat("AnimatorController must not be null.");
                    return;
                }

                int index     = -1;
                var paramList = controller.parameters.ToList();
                var param     = paramList.FirstOrDefault(p => p.name == Node.AnimParam.Name);
                if (param != null)
                {
                    index = paramList.IndexOf(param);
                }

                drawRect.x    += ContentMargin;
                drawRect.width = drawRect.width - ContentMargin * 2;

                drawRect.height = VariantUtils.FieldHeight;
                int newIndex = EditorGUI.Popup(drawRect, index, paramList.Select(p => p.name).ToArray());
                if (newIndex != index)
                {
                    SetNewParam(paramList[newIndex]);
                }

                if (string.IsNullOrWhiteSpace(Node.AnimParam?.HoldType?.Metadata))
                {
                    drawRect.y += drawRect.height;
                    VariantUtils.DrawParameter(drawRect, Node.AnimParam, false);
                }
            }
            else
            {
                EditorGUI.HelpBox(drawRect, "AnimController is required!", MessageType.Error);
            }
        }
Example #8
0
        public void OnGUI(Rect position, SerializedProperty property, GUIContent label,
                          SerializedType fieldType, PropertyAttribute attribute, bool displayLock = true)
        {
            SetContentForParameters();

            int  index       = -1;
            bool wasConstant = AsParametrized.IsParameterConstant(property.name);
            var  setParam    = AsParametrized.GetParameter(property.name, fieldType);
            var  param       = setParam?.Get(DataProvider);

            if (param != null)
            {
                index = Parameters.FindIndex(p => p.Name.Equals(param.Name) && p.GetHoldType().Equals(param.GetHoldType()));
            }

            DrawBackground(position, index != -1 || wasConstant);

            label = EditorGUI.BeginProperty(position, label, property);
            {
                position.y += BoxBackgroundHeight * 0.5f;
                position    = EditorGUI.PrefixLabel(position, new GUIContent(property.displayName));

                EditorGUI.indentLevel = 0;
                EditorGUI.BeginChangeCheck();
                {
                    var fieldRect = position;

                    if (displayLock)
                    {
                        var lockRect = new Rect(fieldRect.x + fieldRect.width - LockSize, fieldRect.y + 2, LockSize,
                                                fieldRect.height);

                        bool isConstant = EditorGUI.Toggle(lockRect, wasConstant, SpaceEditorStyles.LockButton);

                        fieldRect.width -= LockSize;

                        if (isConstant)
                        {
                            Variant value = wasConstant ? AsParametrized.GetVariant(property.name, fieldType) : new Variant(fieldType);

                            VariantUtils.DrawParameter(fieldRect, value, false);

                            AsParametrized.SetParameterConst(property.name, value);
                        }
                        else
                        {
                            DrawParamField(ref fieldRect, ref index, property, wasConstant != isConstant);
                        }
                    }
                    else
                    {
                        DrawParamField(ref fieldRect, ref index, property);
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(Target);
                }
            }
            EditorGUI.EndProperty();
        }