private void Add_Valid_System(VFXGraph graph) { var spawnerContext = ScriptableObject.CreateInstance <VFXBasicSpawner>(); var blockConstantRate = ScriptableObject.CreateInstance <VFXSpawnerConstantRate>(); var slotCount = blockConstantRate.GetInputSlot(0); var basicInitialize = ScriptableObject.CreateInstance <VFXBasicInitialize>(); var quadOutput = ScriptableObject.CreateInstance <VFXPlanarPrimitiveOutput>(); quadOutput.SetSettingValue("blendMode", VFXAbstractParticleOutput.BlendMode.Additive); var setPosition = ScriptableObject.CreateInstance <Block.SetAttribute>(); //only needed to allocate a minimal attributeBuffer setPosition.SetSettingValue("attribute", "position"); setPosition.inputSlots[0].value = VFX.Position.defaultValue; basicInitialize.AddChild(setPosition); slotCount.value = 1.0f; spawnerContext.AddChild(blockConstantRate); graph.AddChild(spawnerContext); graph.AddChild(basicInitialize); graph.AddChild(quadOutput); basicInitialize.LinkFrom(spawnerContext); quadOutput.LinkFrom(basicInitialize); }
private void CreateAssetAndComponent(float spawnCountValue, string playEventName, out VFXGraph graph, out VisualEffect vfxComponent, out GameObject gameObj, out GameObject cameraObj) { EditorApplication.ExecuteMenuItem("Window/General/Game"); graph = MakeTemporaryGraph(); var eventStart = ScriptableObject.CreateInstance <VFXBasicEvent>(); eventStart.eventName = playEventName; var spawnerContext = ScriptableObject.CreateInstance <VFXBasicSpawner>(); var blockConstantRate = ScriptableObject.CreateInstance <VFXSpawnerConstantRate>(); var slotCount = blockConstantRate.GetInputSlot(0); var spawnerInit = ScriptableObject.CreateInstance <VFXBasicInitialize>(); var spawnerOutput = ScriptableObject.CreateInstance <VFXPlanarPrimitiveOutput>(); slotCount.value = spawnCountValue; spawnerContext.AddChild(blockConstantRate); graph.AddChild(eventStart); graph.AddChild(spawnerContext); graph.AddChild(spawnerInit); graph.AddChild(spawnerOutput); spawnerContext.LinkFrom(eventStart, 0, 0); spawnerInit.LinkFrom(spawnerContext); spawnerOutput.LinkFrom(spawnerInit); graph.RecompileIfNeeded(); gameObj = new GameObject("CreateAssetAndComponentSpawner"); vfxComponent = gameObj.AddComponent <VisualEffect>(); vfxComponent.visualEffectAsset = graph.visualEffectResource.asset; cameraObj = new GameObject("CreateAssetAndComponentSpawner_Camera"); var camera = cameraObj.AddComponent <Camera>(); camera.transform.localPosition = Vector3.one; camera.transform.LookAt(vfxComponent.transform); }