public static void DrawAParticleSystem(AParticleSystem aps) { aps.particleSystem = EditorGUILayout.ObjectField("Particle System:", aps.particleSystem, typeof(ParticleSystem), false) as ParticleSystem; aps.loop = EditorGUILayout.ToggleLeft("Loop", aps.loop); /* Create some space */ GUILayout.Space(20f); /* Choose direction */ GUILayout.BeginHorizontal(); GUILayout.Label("Direction to play in:"); aps.direction = (AnimObject.AnimationDirection)EditorGUILayout.EnumPopup( "", aps.direction, GUILayout.MaxWidth(250f)); GUILayout.EndHorizontal(); /* Show distance if location != Target or None */ if (aps.direction != AnimObject.AnimationDirection.Target && aps.direction != AnimObject.AnimationDirection.None) { aps.distance = EditorGUILayout.IntField("Distance (hexes):", aps.distance); } aps.speed = EditorGUILayout.FloatField("Speed:", aps.speed); aps.speed = AnimObject.EnsureNoNegativeFloat(aps.speed); /* Create some space */ GUILayout.Space(20f); /* Draws concurrency/target stuff */ DrawBaseAnimObject(aps); }
// Update is called once per frame void Update() { // Clear particle systems that are not alive foreach (AParticleSystem p in m_particleSystems) { if (!p.IsAlive()) { p.Destroy(); } } m_particleSystems.RemoveAll(item => item == null); if (!m_enableDust) { return; } if (m_leftFootGroundContact != m_jointController.m_leftFootGroundContact) { m_leftFootGroundContact = m_jointController.m_leftFootGroundContact; // Left foot starts to contact the ground if (m_leftFootGroundContact) { GameObject dustObject = Instantiate(m_dustParticleSystem); AParticleSystem dust = dustObject.GetComponent <AParticleSystem>(); dust.m_position = m_jointController.m_leftFoot.transform.position; m_particleSystems.Add(dust); } } if (m_rightFootGroundContact != m_jointController.m_rightFootGroundContact) { m_rightFootGroundContact = m_jointController.m_rightFootGroundContact; // Right foot starts to contact the ground if (m_rightFootGroundContact) { GameObject dustObject = Instantiate(m_dustParticleSystem); AParticleSystem dust = dustObject.GetComponent <AParticleSystem>(); dust.m_position = m_jointController.m_rightFoot.transform.position; m_particleSystems.Add(dust); } } }
/// <summary> /// Unity Editor GUI call, which is called every update frame. /// </summary> void OnGUI() { _animObjectType = (AnimObject.AnimObjectType)EditorGUILayout.EnumPopup("AnimObject Type:", _animObjectType, GUILayout.MaxWidth(300f)); if (_animObjectType == AnimObject.AnimObjectType.AParticleSystem) { ShowParticleSystemVariables(); } else if (_animObjectType == AnimObject.AnimObjectType.ASpriteAnimation) { ShowSpriteAnimationVariables(); } else if (_animObjectType == AnimObject.AnimObjectType.ATween) { ShowTweenVariables(); } GUILayout.Space(100f); /* Show OK/Close buttons */ if (GUILayout.Button("Create New AnimObject")) { switch (_animObjectType) { case AnimObject.AnimObjectType.ATween: ATween newTween = AnimObject.CreateTweenAnimObject(); newTween.speed = tweenSpeed; newTween.direction = tweenDirection; newTween.distance = tweenDistance; SetCommonVariables(newTween); _targetAOH.AddToCollection(newTween); break; case AnimObject.AnimObjectType.ASpriteAnimation: ASpriteAnimation newSpriteAnimation = AnimObject.CreateSpriteAnimationAnimObject(_targetAnimController.GetComponent <Animator>()); newSpriteAnimation.loop = spriteLoop; newSpriteAnimation.speed = spriteSpeed; //newSpriteAnimation.spriteAnimation = spriteAnimation; newSpriteAnimation.timesToLoop = spriteTimesToLoop; SetCommonVariables(newSpriteAnimation); _targetAOH.AddToCollection(newSpriteAnimation); break; case AnimObject.AnimObjectType.AParticleSystem: AParticleSystem newParticleSystem = AnimObject.CreateParticleSystemAnimObject(); newParticleSystem.loop = particleLoop; newParticleSystem.speed = particleSpeed; newParticleSystem.particleSystem = particleSystem; newParticleSystem.direction = particleDirection; newParticleSystem.distance = particleDistance; SetCommonVariables(newParticleSystem); _targetAOH.AddToCollection(newParticleSystem); break; } this.Close(); } if (GUILayout.Button("Cancel")) { this.Close(); } }