public static void Add( UIParticle particleSource, RectTransform spawnPosition, RectTransform particleCanvas) { M0 m0 = Object.Instantiate <GameObject>((M0)((Component)particleSource).get_gameObject()); ((GameObject)m0).get_transform().SetParent((Transform)spawnPosition, false); Transform transform = ((GameObject)m0).get_transform(); Rect rect1 = spawnPosition.get_rect(); double num1 = (double)Random.Range(0.0f, ((Rect) ref rect1).get_width()); Rect rect2 = spawnPosition.get_rect(); double num2 = (double)((Rect) ref rect2).get_width() * spawnPosition.get_pivot().x; double num3 = num1 - num2; Rect rect3 = spawnPosition.get_rect(); double num4 = (double)Random.Range(0.0f, ((Rect) ref rect3).get_height()); Rect rect4 = spawnPosition.get_rect(); double num5 = (double)((Rect) ref rect4).get_height() * spawnPosition.get_pivot().y; double num6 = num4 - num5; Vector3 vector3 = new Vector3((float)num3, (float)num6, 0.0f); transform.set_localPosition(vector3); ((GameObject)m0).get_transform().SetParent((Transform)particleCanvas, true); ((GameObject)m0).get_transform().set_localScale(Vector3.get_one()); ((GameObject)m0).get_transform().set_localRotation(Quaternion.get_identity()); }
void AnimationIdxCallBack(string sprite) { UIParticle particle = mWidget as UIParticle; particle.Animations[mIndex] = sprite; particle.mHasInitUVs = false; }
void CheckTrail() { if (isActiveAndEnabled && !m_IsTrail && m_ParticleSystem && m_ParticleSystem.trails.enabled) { if (!m_TrailParticle) { m_TrailParticle = new GameObject("[UIParticle] Trail").AddComponent <UIParticle>(); var trans = m_TrailParticle.transform; trans.SetParent(transform); trans.localPosition = Vector3.zero; trans.localRotation = Quaternion.identity; trans.localScale = Vector3.one; m_TrailParticle._renderer = GetComponent <ParticleSystemRenderer>(); m_TrailParticle.m_ParticleSystem = GetComponent <ParticleSystem>(); m_TrailParticle.m_IsTrail = true; } m_TrailParticle.enabled = true; } else if (m_TrailParticle) { m_TrailParticle.enabled = false; } }
void SetDestination(UIParticle particle) { if (direction == Direction.Radius) { Rect rec = this.GetComponent <RectTransform>().rect; var dir = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)).normalized; dir = new Vector2(dir.x * rec.width * 0.5f, dir.y * rec.height * 0.5f); particle.P1 = dir * (innerRadius); particle.P4 = dir; particle.P2 = particle.P1 + (particle.P4 - particle.P1) * 0.33333f; particle.P3 = particle.P1 + (particle.P4 - particle.P1) * 0.66666f; } else if (direction == Direction.Cone) { Rect rec = this.GetComponent <RectTransform>().rect; Vector3 temp = Quaternion.AngleAxis(Random.Range(-Angle, Angle), Vector3.forward) * Vector3.right; var dir = new Vector2(temp.x, temp.y); dir = new Vector2(dir.x * rec.width * 0.5f, dir.y * rec.height * 0.5f); particle.P1 = new Vector2(-rec.width / 2f, 0) * (1F - Threshold) + dir * Threshold; particle.P4 = dir; particle.P2 = particle.P1 + (particle.P4 - particle.P1) * 0.33333f; particle.P3 = particle.P1 + (particle.P4 - particle.P1) * 0.66666f; } }
// Start is called before the first frame update private void Start() { UiParticle = GetComponentInChildren <UIParticle>(); spawnOnUI = GetComponentInChildren <Toggle>(); demo = FindObjectOfType("CFX_Demo_New") as MonoBehaviour ?? FindObjectOfType("WFX_Demo_New") as MonoBehaviour; SetCanvasWidth(800); SetCanvasRenderOverlay(true); }
UIParticle Emit() { if (particlePool.Count > 0) { UIParticle particle = particlePool[0]; particlePool.RemoveAt(0); activeParticles.Add(particle); return(particle); } return(null); }
//static UIParticleEditor() //{ // EditorApplication.hierarchyWindowItemOnGUI += HierarchyItemCB; //} private static void HierarchyItemCB(int instanceid, Rect selectionrect) { return; var obj = EditorUtility.InstanceIDToObject(instanceid) as GameObject; if (obj != null) { if (obj.GetComponent <UIParticle>()) { UIParticle particle = obj.GetComponent <UIParticle>(); Rect r = new Rect(selectionrect); r.x = r.width - 50; r.width = 50; var style = new GUIStyle(); if (particle.Particles == null || particle.Particles.Count == 0) { style.normal.textColor = Color.red; style.hover.textColor = Color.yellow; GUI.Label(r, string.Format("'{0}'", "No Particle!"), style); } else { style.normal.textColor = Color.green; style.hover.textColor = Color.cyan; GUI.Label(r, string.Format("'{0}'", particle.renderQueue.ToString()), style); } } #if SHOW_HIDDEN_OBJECTS && UNITY_EDITOR else if (obj.GetComponent <UIDrawCall>()) { Rect r = new Rect(selectionrect); r.x = r.width - 50; r.width = 50; var style = new GUIStyle(); style.normal.textColor = Color.green; style.hover.textColor = Color.cyan; MeshRenderer mesh = obj.GetComponent <MeshRenderer>(); GUI.Label(r, string.Format("=>'{0}'", mesh.enabled.ToString()), style); } #endif } }
public static void Add(UIParticle particleSource, RectTransform spawnPosition, RectTransform particleCanvas) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(particleSource.gameObject); gameObject.transform.SetParent(spawnPosition, false); Transform vector3 = gameObject.transform; Rect rect = spawnPosition.rect; float single = UnityEngine.Random.Range(0f, rect.width); rect = spawnPosition.rect; float single1 = single - rect.width * spawnPosition.pivot.x; rect = spawnPosition.rect; float single2 = UnityEngine.Random.Range(0f, rect.height); rect = spawnPosition.rect; vector3.localPosition = new Vector3(single1, single2 - rect.height * spawnPosition.pivot.y, 0f); gameObject.transform.SetParent(particleCanvas, true); gameObject.transform.localScale = Vector3.one; gameObject.transform.localRotation = Quaternion.identity; }
protected virtual void OnEnable() { m_uiParticleScript = target as UIParticle; }
public void RemoveParticle(UIParticle particle) { GameObject.Destroy(particle.gameObject); Particles.Remove(particle); }
public void RemoveParticle(UIParticle particle) { NGUITools.Destroy(particle.gameObject); Particles.Remove(particle); }
void AddToPool(UIParticle particle) { inactiveParticles.Add(particle); //activeParticles.Remove (particle); }
override protected bool OnDrawProperties() { UIParticle particle = mWidget as UIParticle; if (!base.OnDrawProperties()) { return(false); } EditorGUILayout.BeginHorizontal(); { particle.mUseFixedSeed = EditorGUILayout.Toggle("UseSeed:", particle.mUseFixedSeed, GUILayout.MinWidth(50f)); particle.mFixedSeed = EditorGUILayout.IntField("FixedSeed:", particle.mFixedSeed, GUILayout.MinWidth(150f)); } EditorGUILayout.EndHorizontal(); particle.mFollowDirection = EditorGUILayout.Toggle("Follow Direction:", particle.mFollowDirection); Vector2 start = EditorGUILayout.Vector2Field("Start Size:", particle.mStartSize); if (start != particle.mStartSize) { NGUIEditorTools.RegisterUndo("Undo ParticleSize", particle); particle.mStartSize = start; } Vector2 end = EditorGUILayout.Vector2Field("End Size:", particle.mEndSize); if (end != particle.mEndSize) { NGUIEditorTools.RegisterUndo("Undo ParticleSize", particle); particle.mEndSize = end; } particle.mSizeCurve = EditorGUILayout.CurveField("Size Curve", particle.mSizeCurve, Color.green, new Rect(0.0f, 0.0f, 1.0f, 1.0f)); SerializedObject serializedObj = new SerializedObject(particle); SerializedProperty serializedProp = serializedObj.FindProperty("mColorGradient"); EditorGUILayout.PropertyField(serializedProp, new GUIContent("Color")); serializedObj.ApplyModifiedProperties(); mShowAniamtions = EditorGUILayout.Foldout(mShowAniamtions, "Aniamtions"); if (mShowAniamtions == true) { int size = EditorGUILayout.IntField("size", particle.Animations.Length); if (size != particle.Animations.Length) { particle.mHasInitUVs = false; int newsize = Mathf.Min(size, particle.Animations.Length); string[] buf = new string[size]; for (int i = 0; i < newsize; i++) { buf[i] = particle.Animations[i]; } particle.Animations = buf; } for (int i = 0; i < particle.Animations.Length; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Sprite") == true) { mIndex = i; SpriteSelector.Show(AnimationIdxCallBack); } //particle.Animations[i] = EditorGUILayout.TextField(particle.Animations[i]); string name = EditorGUILayout.TextField(particle.Animations[i]); if (name != particle.Animations[i]) { particle.Animations[i] = name; particle.mHasInitUVs = false; } EditorGUILayout.EndHorizontal(); } } particle.Loop = EditorGUILayout.IntField("Loop", particle.Loop); particle.mUseParticleSize = EditorGUILayout.Toggle("Use Size", particle.mUseParticleSize); return(true); }
protected override void DrawCustomProperties() { UIParticle particle = target as UIParticle; GUILayout.BeginHorizontal(); if (GUILayout.Button("Reset Particles")) { if (EditorUtility.DisplayDialogComplex("重置控件", "重置控件会导致特效顺序重置!", "YES", "NO", "Cancel") == 0) { particle.RefreshParticles(); serializedObject.ApplyModifiedProperties(); } } if (GUILayout.Button("Play")) { if (Application.isPlaying) { particle.Play(1f); } } if (GUILayout.Button("Loop")) { if (Application.isPlaying) { particle.Play(-1f); } } GUILayout.EndHorizontal(); if (particle.Particles == null || particle.Particles.Count == 0) { var style = new GUIStyle(); style.normal.textColor = Color.red; style.hover.textColor = Color.yellow; GUILayout.Label("No Particle exits in children!", style); } else { serializedObject.Update(); ReorderableListGUI.Title("Particles"); ReorderableListGUI.ListField(_particlesProperty, ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.HideAddButton | ReorderableListFlags.ShowIndices); serializedObject.FindProperty("extraRQ").intValue = _particlesProperty.arraySize > 0 ? _particlesProperty.arraySize - 1 : 0; serializedObject.ApplyModifiedProperties(); //GUILayout.BeginHorizontal(); NGUIEditorTools.DrawProperty("animator", serializedObject, "animator", GUILayout.MinWidth(20f)); if (particle.animator != null) { NGUIEditorTools.DrawProperty("↘defaultClip", serializedObject, "defaultClip", GUILayout.MinWidth(20f)); } //GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); NGUIEditorTools.DrawProperty("playOnAwake", serializedObject, "playOnAwake", GUILayout.MinWidth(20f)); if (particle.playOnAwake) { NGUIEditorTools.DrawProperty("duration", serializedObject, "duration", GUILayout.MinWidth(20f)); } GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(true); GUILayout.BeginHorizontal(); NGUIEditorTools.DrawProperty("extraRQ", serializedObject, "extraRQ", GUILayout.MinWidth(20f)); NGUIEditorTools.DrawProperty("RQ", serializedObject, "renderQueue", GUILayout.MinWidth(20f)); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); #if UNITY_EDITOR //if (lastRQ != particle.renderQueue || particle.Particles != particles) //{ // lastRQ = particle.renderQueue; // particle.ResetRQ(); // EditorApplication.RepaintHierarchyWindow(); //} #endif base.DrawCustomProperties(); } particles.Clear(); particles.AddRange(particle.Particles); }
void OnDisable() { m_uiParticleScript = null; }
void Start() { _instance = this; _ps = gameObject.GetComponent <ParticleSystem>(); }
void Start() { _instance = this; _ps = gameObject.GetComponent<ParticleSystem>(); }