Пример #1
0
        public EditableFloatVectorType(ConstantNodeModel model, string propertyPath, IEnumerable <string> propertyNames)
        {
            m_Model = model;

            PropertyNames  = propertyNames.Select(p => propertyPath + "." + p).ToList();
            PropertyLabels = propertyNames.Select(p => p.ToUpper()).ToList();
        }
        public static IEnumerable <object[]> GetTypeAndMatchingConstantNodeModelType()
        {
            EcsStencil ecsStencil = new EcsStencil();
            GraphModel graphModel = Activator.CreateInstance <VSGraphModel>();

            graphModel.Stencil = ecsStencil;

            foreach (var baseType in new[] { typeof(ConstantNodeModel <>), typeof(ConstantNodeModel <,>) })
            {
                foreach (var concreteType in GetTypes(ecsStencil, baseType))
                {
                    ConstantNodeModel nodeModel = (ConstantNodeModel)Activator.CreateInstance(concreteType);
                    nodeModel.GraphModel = graphModel;
                    var constantValueType = nodeModel.Type.GenerateTypeHandle(ecsStencil);
                    yield return(new object[] { ecsStencil, constantValueType, concreteType });
                }
            }
        }
Пример #3
0
        static object[] MakeEdgeActionSetup <TAction>(TestContext ctx, int numEdges,
                                                      Func <VSGraphModel, TAction> getAction, State.UIRebuildType rebuildType = State.UIRebuildType.Partial)
            where TAction : IAction
        {
            Func <VSGraphModel, TAction> f = graphModel =>
            {
                ctx.InputPorts.Capacity  = numEdges;
                ctx.OutputPorts.Capacity = numEdges;
                ctx.InputPorts.Clear();
                ctx.OutputPorts.Clear();
                for (int i = 0; i < numEdges; i++)
                {
                    ConstantNodeModel      c  = (ConstantNodeModel)graphModel.CreateConstantNode("Const" + i, typeof(int).GenerateTypeHandle(graphModel.Stencil), Vector2.zero);
                    UnaryOperatorNodeModel op = graphModel.CreateUnaryOperatorNode(UnaryOperatorKind.Minus, Vector2.zero);
                    ctx.InputPorts.Add(op.InputPort as PortModel);
                    ctx.OutputPorts.Add(c.OutputPort as PortModel);
                }

                return(getAction(graphModel));
            };

            return(new object[] { typeof(TAction).Name, rebuildType, f });
        }
 public static VisualElement BuildFloat4Editor(this IConstantEditorBuilder builder, ConstantNodeModel <Vector4, float4> v)
 {
     return(builder.BuildVectorEditor(new EditableFloatVectorType(v, "m_NodeModel.value", new [] { "x", "y", "z", "w" })));
 }
Пример #5
0
        public static InlineFloatEditor MakeFloatVectorEditor <T>(this IConstantEditorBuilder builder, ConstantNodeModel <T> model, IEnumerable <string> fieldNames, Func <T, int, float> getField, VectorType <T, float> .SetFieldDelegate setField)
        {
            var vectorType = new VectorType <T, float>(model.value, fieldNames, getField, setField);

            return(builder.MakeVectorEditor(vectorType, (label, fieldValue) => new FloatField(label)
            {
                value = fieldValue
            }));
        }
Пример #6
0
        public static InlineFloatEditor MakeFloatVectorEditor <T>(this IConstantEditorBuilder builder, ConstantNodeModel <T> model, int vectorSize, Func <T, int, float> getField, VectorType <T, float> .SetFieldDelegate setField)
        {
            var fieldNames = s_VectorParamNames.Take(vectorSize).Select(c => c.ToString());

            return(builder.MakeFloatVectorEditor(model, fieldNames, getField, setField));
        }
Пример #7
0
 public static VisualElement BuildVector3Editor(this IConstantEditorBuilder builder, ConstantNodeModel <Vector3> v)
 {
     return(builder.MakeFloatVectorEditor(v, 3,
                                          (vec, i) => vec[i], (ref Vector3 data, int i, float value) => data[i] = value));
 }
Пример #8
0
 public static VisualElement BuildStringEditor(this IConstantEditorBuilder builder, ConstantNodeModel <string> s)
 {
     return(builder.BuildSingleFieldEditor(s.value, new TextField()));
 }
        public static VisualElement BuildVector4Editor(this IConstantEditorBuilder builder, ConstantNodeModel <Vector4> v)
        {
            var root = new VisualElement();

            root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.TemplatePath + "ConstantEditors.uss"));
            root.AddToClassList("vs-inline-float-editor");

            CreateField("x", builder, root, v.value, v.value.x, ChangeX);
            CreateField("y", builder, root, v.value, v.value.y, ChangeY);
            CreateField("z", builder, root, v.value, v.value.z, ChangeZ);
            CreateField("w", builder, root, v.value, v.value.w, ChangeW);

            return(root);

            //Local Functions
            Vector4 ChangeX(ChangeEvent <float> evt) => new Vector4(evt.newValue, v.value.y, v.value.z, v.value.w);
            Vector4 ChangeY(ChangeEvent <float> evt) => new Vector4(v.value.x, evt.newValue, v.value.z, v.value.w);
            Vector4 ChangeZ(ChangeEvent <float> evt) => new Vector4(v.value.x, v.value.y, evt.newValue, v.value.w);
            Vector4 ChangeW(ChangeEvent <float> evt) => new Vector4(v.value.x, v.value.y, v.value.z, evt.newValue);
        }
Пример #10
0
 public static VisualElement BuildIntEditor(this IConstantEditorBuilder builder, ConstantNodeModel <int> i)
 {
     return(builder.BuildSingleFieldEditor(i.value, new IntegerField()));
 }
Пример #11
0
 public static VisualElement BuildDoubleEditor(this IConstantEditorBuilder builder, ConstantNodeModel <double> d)
 {
     return(builder.BuildSingleFieldEditor(d.value, new DoubleField()));
 }
Пример #12
0
 public static VisualElement BuildFloatEditor(this IConstantEditorBuilder builder, ConstantNodeModel <float> f)
 {
     return(builder.BuildSingleFieldEditor(f.value, new FloatField()));
 }
Пример #13
0
 public static VisualElement BuildColorEditor(this IConstantEditorBuilder builder, ConstantNodeModel <Color> c)
 {
     return(builder.BuildSingleFieldEditor(c.value, new ColorField()));
 }
Пример #14
0
 public static VisualElement BuildQuaternionEditor(this IConstantEditorBuilder builder, ConstantNodeModel <Quaternion> q)
 {
     return(null);
 }
 public static VisualElement BuildQuaternionEditor(this IConstantEditorBuilder builder, ConstantNodeModel <Quaternion> q)
 {
     return(builder.MakeFloatVectorEditor(q, 4,
                                          (vec, i) => vec[i], (ref Quaternion data, int i, float value) => data[i] = value));
 }
Пример #16
0
        public static VisualElement BuildFloat2Editor(this IConstantEditorBuilder builder, ConstantNodeModel <float2> f)
        {
            var root = new VisualElement();

            root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.TemplatePath + "ConstantEditors.uss"));
            root.AddToClassList("vs-inline-float-editor");
            CreateField("x", builder, root, f.value, f.value.x, ChangeX);
            CreateField("y", builder, root, f.value, f.value.y, ChangeY);

            return(root);

            float2 ChangeX(ChangeEvent <float> evt) => new float2(evt.newValue, f.value.y);
            float2 ChangeY(ChangeEvent <float> evt) => new float2(f.value.x, evt.newValue);
        }
Пример #17
0
 public static VisualElement BuildFloat4Editor(this IConstantEditorBuilder builder, ConstantNodeModel <float4> f)
 {
     return(builder.MakeFloatVectorEditor(f, 4,
                                          (vec, i) => vec[i], (ref float4 data, int i, float value) => data[i] = value));
 }
Пример #18
0
 public static VisualElement BuildBoolEditor(this IConstantEditorBuilder builder, ConstantNodeModel <bool> b)
 {
     return(builder.BuildSingleFieldEditor(b.value, new Toggle()));
 }