本文整理汇总了C#中UnityEngine.ParticleSystem.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleSystem.GetComponent方法的具体用法?C# ParticleSystem.GetComponent怎么用?C# ParticleSystem.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem.GetComponent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
private void Awake()
{
_explosionParticles = Instantiate(ExplosionPrefab).GetComponent<ParticleSystem>();
_explosionAudio = _explosionParticles.GetComponent<AudioSource>();
_explosionParticles.gameObject.SetActive(false);
}
示例2: ParticleState
public ParticleState( AmplifyMotionCamera owner, AmplifyMotionObjectBase obj )
: base( owner, obj )
{
m_particleSystem = m_obj.GetComponent<ParticleSystem>();
m_renderer = m_particleSystem.GetComponent<ParticleSystemRenderer>();
rotationOverLifetime = m_particleSystem.rotationOverLifetime;
rotationBySpeed = m_particleSystem.rotationBySpeed;
}
示例3: Awake
private void Awake()
{
// Instantiate the explosion prefab and get a reference to the particle system on it.
m_ExplosionParticles = Instantiate (m_ExplosionPrefab).GetComponent<ParticleSystem> ();
// Get a reference to the audio source on the instantiated prefab.
m_ExplosionAudio = m_ExplosionParticles.GetComponent<AudioSource> ();
// Disable the prefab so it can be activated when it's required.
m_ExplosionParticles.gameObject.SetActive (false);
}
示例4: RescaleParticles
private void RescaleParticles(ParticleSystem particleSystem, float factor)
{
Undo.RecordObject(particleSystem, "Scale Particles");
// the public ParticleSystem api doesn't expose all the parameters that we need to change when scaling the particle system,
// so we need to go direct into the serialized object and poke the properties there.
SerializedObject system = new SerializedObject(particleSystem);
system.FindProperty("InitialModule.startSize.scalar").floatValue *= factor;
system.FindProperty("InitialModule.startSpeed.scalar").floatValue *= factor;
system.FindProperty("InitialModule.gravityModifier").floatValue *= factor;
system.FindProperty("ShapeModule.radius").floatValue *= factor;
system.FindProperty("ShapeModule.boxX").floatValue *= factor;
system.FindProperty("ShapeModule.boxY").floatValue *= factor;
system.FindProperty("ShapeModule.boxZ").floatValue *= factor;
system.FindProperty("VelocityModule.x.scalar").floatValue *= factor;
system.FindProperty("VelocityModule.y.scalar").floatValue *= factor;
system.FindProperty("VelocityModule.z.scalar").floatValue *= factor;
system.FindProperty("ClampVelocityModule.x.scalar").floatValue *= factor;
system.FindProperty("ClampVelocityModule.y.scalar").floatValue *= factor;
system.FindProperty("ClampVelocityModule.z.scalar").floatValue *= factor;
system.FindProperty("ForceModule.x.scalar").floatValue *= factor;
system.FindProperty("ForceModule.y.scalar").floatValue *= factor;
system.FindProperty("ForceModule.z.scalar").floatValue *= factor;
system.FindProperty("SizeBySpeedModule.range").vector2Value *= factor;
system.FindProperty("RotationBySpeedModule.range").vector2Value *= factor;
system.FindProperty("ColorBySpeedModule.range").vector2Value *= factor;
system.ApplyModifiedProperties();
ParticleTurbulence turbulence = particleSystem.GetComponent<ParticleTurbulence>();
if (turbulence != null)
{
Undo.RecordObject(turbulence, "Scale Particles");
SerializedObject turb = new SerializedObject(turbulence);
turb.FindProperty("amplitude").floatValue *= factor;
turb.FindProperty("frequency").floatValue /= factor;
turb.ApplyModifiedProperties();
}
}
示例5: On_CosmosReady
void On_CosmosReady()
{
isReady = true;
cacheTransform = Cosmos.instance.SpaceCamera.transform;
// Create particle system
gameObject.AddComponent<ParticleSystem>();
cacheCosmosParticle = GetComponent<ParticleSystem>();
cacheCosmosParticle.playOnAwake = false;
cacheCosmosParticle.enableEmission = false;
cacheCosmosParticle.simulationSpace = ParticleSystemSimulationSpace.Local;
cacheCosmosParticle.emissionRate = 0;
cacheCosmosParticle.startSpeed = 0;
cacheCosmosParticle.startLifetime = Mathf.Infinity;
cacheCosmosParticle.startRotation = Random.Range(-Mathf.PI,Mathf.PI);
cacheCosmosParticle.GetComponent<Renderer>().material = mat;
cacheCosmosParticle.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
cacheCosmosParticle.GetComponent<Renderer>().receiveShadows = false;
// Pre Spawn
for (int i=0; i < maxParticle; i ++) {
Vector3 drift = Vector3.zero;
if (enableDrift){
drift =new Vector3( Random.Range(-1f,1f),Random.Range(-1f,1f),0) * driftSpeed;
}
cacheCosmosParticle.Emit( cacheTransform.position + (UnityEngine.Random.insideUnitSphere * 200), drift, Random.Range(minSize, maxSize ) , Mathf.Infinity, color.Evaluate( Random.Range(0f,1f)));
}
}
示例6: OnInspectorGUI
public override void OnInspectorGUI(ParticleSystem s)
{
if (RendererModuleUI.s_Texts == null)
{
RendererModuleUI.s_Texts = new RendererModuleUI.Texts();
}
RendererModuleUI.RenderMode intValue = (RendererModuleUI.RenderMode)this.m_RenderMode.intValue;
RendererModuleUI.RenderMode renderMode = (RendererModuleUI.RenderMode)ModuleUI.GUIPopup(RendererModuleUI.s_Texts.renderMode, this.m_RenderMode, RendererModuleUI.s_Texts.particleTypes);
if (renderMode == RendererModuleUI.RenderMode.Mesh)
{
EditorGUI.indentLevel++;
this.DoListOfMeshesGUI();
EditorGUI.indentLevel--;
if (intValue != RendererModuleUI.RenderMode.Mesh && this.m_Meshes[0].objectReferenceInstanceIDValue == 0)
{
this.m_Meshes[0].objectReferenceValue = Resources.GetBuiltinResource(typeof(Mesh), "Cube.fbx");
}
}
else
{
if (renderMode == RendererModuleUI.RenderMode.Stretch3D)
{
EditorGUI.indentLevel++;
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.cameraSpeedScale, this.m_CameraVelocityScale);
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.speedScale, this.m_VelocityScale);
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.lengthScale, this.m_LengthScale);
EditorGUI.indentLevel--;
}
}
if (renderMode != RendererModuleUI.RenderMode.Mesh)
{
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.normalDirection, this.m_NormalDirection);
}
if (this.m_Material != null)
{
ModuleUI.GUIObject(RendererModuleUI.s_Texts.material, this.m_Material);
}
ModuleUI.GUIPopup(RendererModuleUI.s_Texts.sortMode, this.m_SortMode, RendererModuleUI.s_Texts.sortTypes);
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.sortingFudge, this.m_SortingFudge);
ModuleUI.GUIPopup(RendererModuleUI.s_Texts.castShadows, this.m_CastShadows, this.m_CastShadows.enumDisplayNames);
ModuleUI.GUIToggle(RendererModuleUI.s_Texts.receiveShadows, this.m_ReceiveShadows);
ModuleUI.GUIFloat(RendererModuleUI.s_Texts.maxParticleSize, this.m_MaxParticleSize);
EditorGUILayout.Space();
EditorGUILayout.SortingLayerField(RendererModuleUI.s_Texts.sortingLayer, this.m_SortingLayerID, ParticleSystemStyles.Get().popup, ParticleSystemStyles.Get().label);
ModuleUI.GUIInt(RendererModuleUI.s_Texts.sortingOrder, this.m_SortingOrder);
this.m_Probes.OnGUI(s.GetComponent<Renderer>(), true);
}
示例7: Start
void Start()
{
targetSystem = GetComponent<ParticleSystem>();
targetRenderer = targetSystem.GetComponent<ParticleSystemRenderer>();
targetRenderer.enabled = false;
}
示例8: OnInspectorGUI
public override void OnInspectorGUI(ParticleSystem s)
{
if (RendererModuleUI.s_Texts == null)
RendererModuleUI.s_Texts = new RendererModuleUI.Texts();
RendererModuleUI.RenderMode intValue = (RendererModuleUI.RenderMode) this.m_RenderMode.intValue;
RendererModuleUI.RenderMode renderMode = (RendererModuleUI.RenderMode) ModuleUI.GUIPopup(RendererModuleUI.s_Texts.renderMode, this.m_RenderMode, RendererModuleUI.s_Texts.particleTypes);
if (renderMode == RendererModuleUI.RenderMode.Mesh)
{
++EditorGUI.indentLevel;
this.DoListOfMeshesGUI();
--EditorGUI.indentLevel;
if (intValue != RendererModuleUI.RenderMode.Mesh && this.m_Meshes[0].objectReferenceInstanceIDValue == 0)
this.m_Meshes[0].objectReferenceValue = Resources.GetBuiltinResource(typeof (Mesh), "Cube.fbx");
}
else if (renderMode == RendererModuleUI.RenderMode.Stretch3D)
{
++EditorGUI.indentLevel;
double num1 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.cameraSpeedScale, this.m_CameraVelocityScale);
double num2 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.speedScale, this.m_VelocityScale);
double num3 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.lengthScale, this.m_LengthScale);
--EditorGUI.indentLevel;
}
if (renderMode != RendererModuleUI.RenderMode.Mesh)
{
double num4 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.normalDirection, this.m_NormalDirection);
}
if (this.m_Material != null)
ModuleUI.GUIObject(RendererModuleUI.s_Texts.material, this.m_Material);
ModuleUI.GUIPopup(RendererModuleUI.s_Texts.sortMode, this.m_SortMode, RendererModuleUI.s_Texts.sortTypes);
double num5 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.sortingFudge, this.m_SortingFudge);
ModuleUI.GUIPopup(RendererModuleUI.s_Texts.castShadows, this.m_CastShadows, this.m_CastShadows.enumDisplayNames);
EditorGUI.BeginDisabledGroup(SceneView.IsUsingDeferredRenderingPath());
ModuleUI.GUIToggle(RendererModuleUI.s_Texts.receiveShadows, this.m_ReceiveShadows);
EditorGUI.EndDisabledGroup();
double num6 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.minParticleSize, this.m_MinParticleSize);
double num7 = (double) ModuleUI.GUIFloat(RendererModuleUI.s_Texts.maxParticleSize, this.m_MaxParticleSize);
EditorGUILayout.Space();
EditorGUILayout.SortingLayerField(RendererModuleUI.s_Texts.sortingLayer, this.m_SortingLayerID, ParticleSystemStyles.Get().popup, ParticleSystemStyles.Get().label);
ModuleUI.GUIInt(RendererModuleUI.s_Texts.sortingOrder, this.m_SortingOrder);
if (renderMode == RendererModuleUI.RenderMode.Billboard)
ModuleUI.GUIPopup(RendererModuleUI.s_Texts.space, this.m_RenderAlignment, RendererModuleUI.s_Texts.spaces);
ModuleUI.GUIVector3Field(RendererModuleUI.s_Texts.pivot, this.m_Pivot);
this.m_Probes.OnGUI((Object[]) null, s.GetComponent<Renderer>(), true);
}
示例9: ParticleState
public ParticleState( AmplifyMotionCamera owner, AmplifyMotionObjectBase obj )
: base( owner, obj )
{
m_particleSystem = m_obj.GetComponent<ParticleSystem>();
m_meshRenderer = m_particleSystem.GetComponent<Renderer>().GetComponent<ParticleSystemRenderer>();
}