Beispiel #1
0
    public override void Sanitize(int version)
    {
        var sourceSpawnCount = ScriptableObject.CreateInstance <VFXAttributeParameter>();

        sourceSpawnCount.SetSettingValue("location", VFXAttributeLocation.Source);
        sourceSpawnCount.SetSettingValue("attribute", VFXAttribute.SpawnCount.name);
        sourceSpawnCount.position = position - new Vector2(300, 100);

        var parent = GetParent();

        if (parent)
        {
            parent.AddChild(sourceSpawnCount);
        }

        var inlineUInt = ScriptableObject.CreateInstance <VFXInlineOperator>();

        inlineUInt.SetSettingValue("m_Type", (SerializableType)typeof(uint));
        sourceSpawnCount.outputSlots[0].Link(inlineUInt.inputSlots[0]);

        VFXSlot.CopyLinksAndValue(inlineUInt.outputSlots[0], outputSlots[0], true);
        ReplaceModel(inlineUInt, this);

        base.Sanitize(version);
    }
Beispiel #2
0
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace SetLifetime with corresponding generic blocks");

            if (mode == SetMode.Constant || mode == SetMode.Random)
            {
                var newBlock = CreateInstance <SetAttribute>();
                newBlock.SetSettingValue("attribute", "lifetime");
                newBlock.SetSettingValue("Random", mode == SetMode.Constant ? RandomMode.Off : RandomMode.Uniform);

                // Transfer links
                VFXSlot.CopyLinksAndValue(newBlock.GetInputSlot(0), GetInputSlot(0), true);
                if (mode == SetMode.Random)
                {
                    VFXSlot.CopyLinksAndValue(newBlock.GetInputSlot(1), GetInputSlot(1), true);
                }
                ReplaceModel(newBlock, this);
            }
            else // Ignore random curve
            {
                var newBlock = CreateInstance <AttributeFromCurve>();
                newBlock.SetSettingValue("attribute", "lifetime");

                // Transfer links
                VFXSlot.CopyLinksAndValue(newBlock.GetInputSlot(0), GetInputSlot(0), true);
                ReplaceModel(newBlock, this);
            }
        }
Beispiel #3
0
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace SetSizeVariadic with SetAttribute");

            var setAttribute = CreateInstance <SetAttribute>();

            setAttribute.SetSettingValue("attribute", "size");
            setAttribute.SetSettingValue("Composition", Composition);
            setAttribute.SetSettingValue("Random", Random);

            switch (SizeMode)
            {
            case Mode.X:
                setAttribute.SetSettingValue("channels", VariadicChannelOptions.X);
                break;

            case Mode.XY:
                setAttribute.SetSettingValue("channels", VariadicChannelOptions.XY);
                break;

            case Mode.XYZ:
                setAttribute.SetSettingValue("channels", VariadicChannelOptions.XYZ);
                break;
            }

            // Transfer links
            var nbSlots = Math.Min(setAttribute.GetNbInputSlots(), GetNbInputSlots());

            for (int i = 0; i < nbSlots; ++i)
            {
                VFXSlot.CopyLinksAndValue(setAttribute.GetInputSlot(i), GetInputSlot(i), true);
            }

            ReplaceModel(setAttribute, this);
        }
        public override void Sanitize(int version)
        {
            var newVolume = ScriptableObject.CreateInstance <Operator.ConeVolume>();

            SanitizeHelper.MigrateTConeFromCone(newVolume.inputSlots[0], inputSlots[0]);
            VFXSlot.CopyLinksAndValue(newVolume.outputSlots[0], outputSlots[0], true);
            ReplaceModel(newVolume, this);
        }
        public override void Sanitize(int version)
        {
            var newArea = ScriptableObject.CreateInstance <Operator.CircleArea>();

            SanitizeHelper.MigrateTCircleFromCircle(newArea.inputSlots[0], inputSlots[0]);
            VFXSlot.CopyLinksAndValue(newArea.outputSlots[0], outputSlots[0], true);
            ReplaceModel(newArea, this);
        }
        public override sealed void Sanitize(int version)
        {
            var crossProduct = ScriptableObject.CreateInstance(typeof(CrossProduct)) as VFXOperatorNumericUniform;

            crossProduct.SetOperandType(typeof(Vector3));
            VFXSlot.CopyLinksAndValue(crossProduct.inputSlots[0], inputSlots[0], true);
            VFXSlot.CopyLinksAndValue(crossProduct.inputSlots[1], inputSlots[1], true);
            VFXSlot.CopyLinks(crossProduct.outputSlots[0], outputSlots[0], true);
            VFXModel.ReplaceModel(crossProduct, this);
        }
Beispiel #7
0
        public static void MigrateVector3OutputToSpaceableKeepingLegacyBehavior(VFXOperator op, string newTypeInfo)
        {
            Debug.LogFormat("Sanitizing Graph: Automatically replace Vector3 to {0} for {1}. An inline Vector3 operator has been added.", newTypeInfo, op.name);

            var inlineVector3 = ScriptableObject.CreateInstance <VFXInlineOperator>();

            inlineVector3.SetSettingValue("m_Type", (SerializableType)typeof(Vector3));
            inlineVector3.position = op.position + new Vector2(128.0f, 64.0f);
            VFXSlot.CopyLinksAndValue(inlineVector3.outputSlots[0], op.outputSlots[0], false /* we should avoid ReSyncSlot at this stage*/);
            op.outputSlots[0].Link(inlineVector3.inputSlots[0], true /* notify here to correctly invalidate */);
            op.GetParent().AddChild(inlineVector3);
        }
Beispiel #8
0
        public override void Sanitize(int version)
        {
            var oldRoughness = inputSlots.FirstOrDefault(s => s.name == "Roughness");

            base.Sanitize(version);
            if (oldRoughness != default(VFXSlot))
            {
                var newRoughness = inputSlots.FirstOrDefault(s => s.name == "roughness");
                if (newRoughness != default(VFXSlot))
                {
                    VFXSlot.CopyLinksAndValue(newRoughness, oldRoughness, true);
                }
            }
        }
Beispiel #9
0
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace SizeOverLife with AttributeOverLife");

            var attributeOverLife = CreateInstance <AttributeOverLife>();

            attributeOverLife.SetSettingValue("attribute", "size");
            attributeOverLife.SetSettingValue("Composition", composition);
            attributeOverLife.SetSettingValue("channels", VariadicChannelOptions.X);

            // Transfer links
            VFXSlot.CopyLinksAndValue(attributeOverLife.GetInputSlot(0), GetInputSlot(0), true);

            ReplaceModel(attributeOverLife, this);
        }
Beispiel #10
0
        public override void Sanitize(int version)
        {
            var oldRoughness = inputSlots.FirstOrDefault(s => s.name == "Roughness");

            base.Sanitize(version);
            if (oldRoughness != default(VFXSlot))
            {
                var newRoughness = inputSlots.FirstOrDefault(s => s.name == "roughness");
                if (newRoughness != default(VFXSlot))
                {
                    VFXSlot.CopyLinksAndValue(newRoughness, oldRoughness, true);
                    var frequency = inputSlots.FirstOrDefault(s => s.name == "frequency");
                    frequency.UnlinkAll();
                    frequency.value = 1.5f; // Try to match old turbulence noise
                }
            }
        }
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace AttributeOverLife with AttributeFromCurve");

            var attributeFromCurve = CreateInstance <AttributeFromCurve>();

            attributeFromCurve.SetSettingValue("attribute", attribute);
            attributeFromCurve.SetSettingValue("Composition", Composition);
            attributeFromCurve.SetSettingValue("Mode", (AttributeFromCurve.ComputeMode)Mode);
            attributeFromCurve.SetSettingValue("SampleMode", AttributeFromCurve.CurveSampleMode.OverLife);
            attributeFromCurve.SetSettingValue("channels", channels);

            // Transfer links
            VFXSlot.CopyLinksAndValue(attributeFromCurve.GetInputSlot(0), GetInputSlot(0), true);

            ReplaceModel(attributeFromCurve, this);
        }
Beispiel #12
0
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace FitClamped with Remap");

            var remap = CreateInstance <RemapDeprecated>();

            remap.SetSettingValue("Clamp", true);

            // Transfer links
            for (int i = 0; i < 5; ++i)
            {
                VFXSlot.CopyLinksAndValue(remap.GetInputSlot(i), GetInputSlot(i), true);
            }
            VFXSlot.CopyLinksAndValue(remap.GetOutputSlot(0), GetOutputSlot(0), true);

            ReplaceModel(remap, this);
            remap.Sanitize();
        }
Beispiel #13
0
        public void Slot_Copy_Link_OrientedBox_To_Transform()
        {
            var sourceOfLink = ScriptableObject.CreateInstance <VFXInlineOperator>();

            sourceOfLink.SetSettingValue("m_Type", (SerializableType)typeof(float));

            var transform = ScriptableObject.CreateInstance <VFXInlineOperator>();

            transform.SetSettingValue("m_Type", (SerializableType)typeof(Transform));

            var orientedBox = ScriptableObject.CreateInstance <VFXInlineOperator>();

            orientedBox.SetSettingValue("m_Type", (SerializableType)typeof(OrientedBox));

            Assert.IsTrue(orientedBox.inputSlots[0][0][0].Link(sourceOfLink.outputSlots[0]));
            VFXSlot.CopyLinksAndValue(transform.inputSlots[0], orientedBox.inputSlots[0], true);
            Assert.IsTrue(transform.inputSlots[0][0][0].HasLink());
        }
Beispiel #14
0
        public override void Sanitize(int version)
        {
            var oldLineSlot = inputSlots.FirstOrDefault(o => o.name == "line");

            if (oldLineSlot != null)
            {
                RemoveSlot(oldLineSlot); //Avoid unlink
            }

            base.Sanitize(version);
            if (oldLineSlot != null)
            {
                var start = inputSlots.FirstOrDefault(o => o.name == "Start");
                var end   = inputSlots.FirstOrDefault(o => o.name == "End");
                VFXSlot.CopyLinksAndValue(start, oldLineSlot.children.ElementAt(0), true);
                VFXSlot.CopyLinksAndValue(end, oldLineSlot.children.ElementAt(1), true);
                oldLineSlot.UnlinkAll();
            }
        }
        public override void Sanitize(int version)
        {
            Debug.Log("Sanitizing Graph: Automatically replace SimplexNoise with PerlinNoise");

            var perlinNoise = CreateInstance <PerlinNoise>();

            perlinNoise.SetSettingValue("dimensions", dimensions);

            // Transfer links
            for (int i = 0; i < 6; i++)
            {
                VFXSlot.CopyLinksAndValue(perlinNoise.GetInputSlot(i), GetInputSlot(i), true);
            }

            VFXSlot.CopyLinksAndValue(perlinNoise.GetOutputSlot(0), GetOutputSlot(0), true);

            ReplaceModel(perlinNoise, this);

            base.Sanitize(version);
        }
        protected void Sanitize(NoiseBase.NoiseType noiseType)
        {
            if (type == NoiseType.Default)
            {
                var noise = CreateInstance <Noise>();

                noise.SetSettingValue("type", noiseType);
                noise.SetSettingValue("dimensions", (Noise.DimensionCount)dimensions);

                // Transfer links
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(0), GetInputSlot(0), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(1), GetInputSlot(2), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(2), GetInputSlot(3), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(3), GetInputSlot(4), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(5), GetInputSlot(5), true);

                VFXSlot.CopyLinksAndValue(noise.GetOutputSlot(0), GetOutputSlot(0), true);
                VFXSlot.CopyLinksAndValue(noise.GetOutputSlot(1), GetOutputSlot(1), true);

                ReplaceModel(noise, this);
            }
            else
            {
                var noise = CreateInstance <CurlNoise>();

                noise.SetSettingValue("type", noiseType);
                noise.SetSettingValue("dimensions", (CurlNoise.DimensionCount)curlDimensions);

                // Transfer links
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(0), GetInputSlot(0), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(1), GetInputSlot(2), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(2), GetInputSlot(3), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(3), GetInputSlot(4), true);
                VFXSlot.CopyLinksAndValue(noise.GetInputSlot(5), GetInputSlot(1), true);

                VFXSlot.CopyLinksAndValue(noise.GetOutputSlot(0), GetOutputSlot(0), true);

                ReplaceModel(noise, this);
            }
        }
Beispiel #17
0
        public override void Sanitize()
        {
            Debug.Log("Sanitizing Graph: Automatically replace ComponentMask with Swizzle");

            var swizzle = CreateInstance <SwizzleDeprecated>();
            var mask    = new Component[4] {
                x, y, z, w
            };

            string result = "";

            foreach (var m in mask)
            {
                if (m != Component.None)
                {
                    switch (x)
                    {
                    case Component.X: result += 'x'; break;

                    case Component.Y: result += 'y'; break;

                    case Component.Z: result += 'z'; break;

                    case Component.W: result += 'w'; break;

                    default:
                        break;
                    }
                }
            }

            swizzle.SetSettingValue("mask", result);

            // Transfer links
            VFXSlot.CopyLinksAndValue(swizzle.GetInputSlot(0), GetInputSlot(0), true);
            VFXSlot.CopyLinksAndValue(swizzle.GetOutputSlot(0), GetOutputSlot(0), true);

            ReplaceModel(swizzle, this);
            swizzle.Sanitize();
        }
Beispiel #18
0
        public void Slot_Copy_Value_Position_To_Vector3()
        {
            var vector3 = ScriptableObject.CreateInstance <VFXInlineOperator>();

            vector3.SetSettingValue("m_Type", (SerializableType)typeof(Vector3));

            var position = ScriptableObject.CreateInstance <VFXInlineOperator>();

            position.SetSettingValue("m_Type", (SerializableType)typeof(Position));

            var v3_Ref = new Vector3(1, 2, 3);

            position.inputSlots[0].value = (Position)v3_Ref;

            VFXSlot.CopyLinksAndValue(vector3.inputSlots[0], position.inputSlots[0], true);

            var vector3Value = (Vector3)vector3.inputSlots[0].value;

            Assert.AreEqual(v3_Ref.x, vector3Value.x);
            Assert.AreEqual(v3_Ref.y, vector3Value.y);
            Assert.AreEqual(v3_Ref.y, vector3Value.y);
        }
Beispiel #19
0
        public void Slot_Copy_Link_Position_To_Vector3([ValueSource("linkSubSlotOnly")] bool linkSubSlotOnly)
        {
            var sourceOfLink = ScriptableObject.CreateInstance <VFXInlineOperator>();

            sourceOfLink.SetSettingValue("m_Type", (SerializableType)typeof(Vector3));

            var position = ScriptableObject.CreateInstance <VFXInlineOperator>();

            position.SetSettingValue("m_Type", (SerializableType)typeof(Position));

            bool linkSucceed;

            if (linkSubSlotOnly)
            {
                linkSucceed = position.inputSlots[0][0][0].Link(sourceOfLink.outputSlots[0][0]);
            }
            else
            {
                linkSucceed = position.inputSlots[0].Link(sourceOfLink.outputSlots[0]);
            }
            Assert.IsTrue(linkSucceed);

            var vector3 = ScriptableObject.CreateInstance <VFXInlineOperator>();

            vector3.SetSettingValue("m_Type", (SerializableType)typeof(Vector3));

            VFXSlot.CopyLinksAndValue(vector3.inputSlots[0], position.inputSlots[0], true);

            if (linkSubSlotOnly)
            {
                Assert.IsTrue(vector3.inputSlots[0][0].HasLink());
            }
            else
            {
                Assert.IsTrue(vector3.inputSlots[0].HasLink());
            }
        }