public Emitter(EffectLayer owner) { Layer = owner; EmitLoop = Layer.EmitLoop; EmitDist = Layer.DiffDistance; LastClientPos = Layer.ClientTransform.position; }
public ColorAffector(EffectLayer owner, EffectNode node) : base(node, AFFECTORTYPE.ColorAffector) { mOwner = owner; if (owner.ColorGradualTimeLength < 0) IsNodeLife = true; if (mOwner.ColorChangeType == COLOR_CHANGE_TYPE.Random) { mRandomKey = Random.Range(0f,1f); } }
public EffectNode dummyNode;//will not be added to the activenode list. so will not be rendered, just to calc uv anim. public void Init(EffectLayer owner) { Owner = owner; Vertexsegment = owner.GetVertexPool().GetRopeVertexSeg(owner.MaxENodes); dummyNode = new EffectNode(0, owner.ClientTransform, false, owner); List<Affector> afts = owner.InitAffectors(dummyNode); dummyNode.SetAffectorList(afts); dummyNode.SetRenderType(4); //use infinite life. dummyNode.Init(Vector3.zero, 0f, -1f, 0, 1f, 1f, Color.clear, Vector2.zero, Vector2.one); }
protected int Type; //1 sprite, 2 ribbon trail, 3 cone, 4, custom mesh. #endregion Fields #region Constructors public EffectNode(int index, Transform clienttrans, bool sync, EffectLayer owner) { Index = index; ClientTrans = clienttrans; SyncClient = sync; Owner = owner; LowerLeftUV = Vector2.zero; UVDimensions = Vector2.one; Scale = Vector2.one; RotateAngle = 0; Color = Color.white; }
public Emitter(EffectLayer owner) { Layer = owner; EmitLoop = Layer.EmitLoop; LastClientPos = Layer.ClientTransform.position; }
public void Update() { CurTime = Time.realtimeSinceStartup; float deltaTime = (float)(CurTime - LastTime); #if UNITY_EDITOR if (!EditorApplication.isPlaying) { if (!EditView || EditorUtility.IsPersistent(gameObject)) { return; } CurTime = EditorApplication.timeSinceStartup; if (!CheckEditModeInited()) { ResetEditScene(); } deltaTime = (float)(CurTime - LastTime); deltaTime *= PlaybackTime; } #endif //simple method to check game delay: the game must run above 10 FPS. if (deltaTime > 0.1f) { deltaTime = 0.0333f; } if (Paused) { LastTime = CurTime; return; } if (!UpdateWhenOffScreen && !IsInCameraView() && !EditView) { LastTime = CurTime; return; } if (!IgnoreTimeScale) { deltaTime *= Time.timeScale; } ElapsedTime += deltaTime; for (int i = 0; i < EflList.Count; i++) { if (EflList[i] == null)//be destroyed? { return; } EffectLayer el = EflList[i]; if (ElapsedTime > el.StartTime && IsActive(el.gameObject)) { el.FixedUpdateCustom(deltaTime); } } for (int i = 0; i < EventList.Count; i++) { XftEventComponent e = EventList[i]; if (IsActive(e.gameObject)) { e.UpdateCustom(deltaTime); } } LastTime = CurTime; #if UNITY_EDITOR if (!EditorApplication.isPlaying) { LateUpdate(); } #endif }
public void Initialize() { if (CheckEditModeInited()) {//already inited. return; } List <GameObject> tobeDeleted = new List <GameObject>(); //if it's instantiated, delete all the old meshes. foreach (Transform child in transform) { if (child.gameObject.name.Contains("xftmesh")) { tobeDeleted.Add(child.gameObject); } } foreach (Transform child in transform) { EffectLayer el = (EffectLayer)child.GetComponent(typeof(EffectLayer)); if (el == null) { continue; } if (el.Material == null) { Debug.LogWarning("effect layer: " + el.gameObject.name + " has no material, please assign a material first!"); continue; } Material mat = el.Material; //ver 1.2.1 mat.renderQueue = mat.shader.renderQueue; mat.renderQueue += el.Depth; EflList.Add(el); if (MergeSameMaterialMesh) { if (!MatDic.ContainsKey(mat.name)) { MeshFilter mf = CreateMeshObj(mat); MatDic[mat.name] = new VertexPool(mf.sharedMesh, mat); } } else { MeshFilter mf = CreateMeshObj(mat); MatList.Add(new VertexPool(mf.sharedMesh, mat)); } } foreach (GameObject obj in tobeDeleted) { DestoryMeshObject(obj); } //now set each gameobject's parent. foreach (GameObject obj in MeshList) { obj.transform.parent = this.transform; //fixed 2012.6.25, obj.transform.position = Vector3.zero; obj.transform.rotation = Quaternion.identity; //fixed 2012.7.11, avoid the lossy scale influence the mesh object. Vector3 realLocalScale = Vector3.zero; realLocalScale.x = 1 / obj.transform.parent.lossyScale.x; realLocalScale.y = 1 / obj.transform.parent.lossyScale.y; realLocalScale.z = 1 / obj.transform.parent.lossyScale.z; obj.transform.localScale = realLocalScale * Scale; } //assign vertex pool. for (int i = 0; i < EflList.Count; i++) { EffectLayer efl = EflList[i]; if (MergeSameMaterialMesh) { efl.Vertexpool = MatDic[efl.Material.name]; } else { if (EflList.Count != MatList.Count) { Debug.LogError("something wrong with the no merge mesh mat list!"); efl.Vertexpool = MatList[0]; continue; } efl.Vertexpool = MatList[i]; } } //start each effect layer. this.transform.localScale = Vector3.one; foreach (EffectLayer el in EflList) { el.StartCustom(); } //add events EventList.Clear(); foreach (Transform child in transform) { XftEventComponent xftevent = child.GetComponent <XftEventComponent>(); if (xftevent == null) { continue; } EventList.Add(xftevent); xftevent.Initialize(this); } Initialized = true; }