//此函数只供SpecialEffect._CopyValues调用外界不许调用 public bool _CopyValues(SpecialEffectElement o) { #if UNITY_EDITOR if (o == null) { return(false); } if (o == this) { return(true); } if (GetType() != o.GetType()) { return(false); } startTime = o.startTime; playTime = o.playTime; isLoop = o.isLoop; return(true); #else //客户端版,此函数永远运行失败 return(false); #endif }
public static void FixElemDelayTime(SpecialEffectElement currElem, float value) { if (null == currElem) { return; } value = (float)Math.Round((double)value, 2); if (value < 0) { return; } SpecialEffectElement parent = GetParentElem(currElem); if ( (parent != null) && (value > parent.playTime) ) { return; } CalcElemStartTimeForDelayTimeChange(currElem, value); FixParentPlayTime(parent, currElem.playTime, currElem); }
public override bool Equals(object o) { if (o == null) { return(false); } if (o != this) { if (base.GetType() != o.GetType()) { return(false); } SpecialEffectElement element = o as SpecialEffectElement; if (this.startTime != element.startTime) { return(false); } if (this.playTime != element.playTime) { return(false); } if (this.playStyle != element.playStyle) { return(false); } } return(true); }
private void _RemoveAllElems() { SpecialEffect currSpe = target as SpecialEffect; currSpe.elems.Clear(); Transform[] trans = currSpe.transform.GetComponentsInChildren <Transform>(); foreach (var t in trans) { if (currSpe.gameObject.transform == t) { continue; } SpecialEffectElement speElem = t.gameObject.GetComponent <SpecialEffectElement>(); if (speElem != null) { //移除所有已绑定的插件 DestroyImmediate(speElem); } } _MarkSpecialEffectDirty(); _UpdateSerializedObjects(); spe.ApplyModifiedProperties(); }
private static bool FixParentPlayTime(SpecialEffectElement parentElem, float currPlayTime, SpecialEffectElement currElem) { bool bRet = true; if ( (null == currElem) ) { return(false); } if (currPlayTime < 0) { return(false); } if ( (parentElem != null) && ((currElem.startTime + currPlayTime) > (parentElem.startTime + parentElem.playTime)) ) { float parentPlayTime = (float)Math.Round((double)(GetElemDelayTime(currElem) + currPlayTime), 2); bRet = FixParentPlayTime(GetParentElem(parentElem), parentPlayTime, parentElem); if (bRet) { parentElem.playTime = parentPlayTime; } } return(bRet); }
private static void CalcElemStartTimeForDelayTimeChange(SpecialEffectElement currElem, float currDelayTime) { float tempTime = 0f; if (null == currElem) { return; } currDelayTime = (float)Math.Round((double)currDelayTime, 2); SpecialEffectElement parent = GetParentElem(currElem); if (parent != null) { tempTime = (float)Math.Round((double)(parent.startTime + currDelayTime), 2); } else { tempTime = currDelayTime; } if (!FixChildrenElemStartTime(currElem, GetChildrenElem(currElem), tempTime)) { return; } currElem.startTime = tempTime; }
public static void FixElemPlayTime(SpecialEffectElement currElem, float value) { if (null == currElem) { return; } value = (float)Math.Round((double)value, 2); if (value < 0) { return; } if (!FixChildrenPlayTime(GetChildrenElem(currElem), value, currElem)) { return; } if (!FixParentPlayTime(GetParentElem(currElem), value, currElem)) { return; } currElem.playTime = value; }
public static bool IsSPEElementLegal(SpecialEffectElement element, out string errorMsg) { bool bRet = true; errorMsg = string.Empty; if (null == element) { errorMsg = "特效元素为Null"; return(false); } Type elemType = element.GetType(); if (elemType == typeof(SpecialEffectAnimation)) { Animation anim = element.gameObject.GetComponent <Animation>(); if ( (null == anim) || (null == anim.clip) ) { errorMsg = element.gameObject.name + "中的animation脚本没有clip动画或者此动画是animator的动画,animation的动画必须是Legacy的属性"; bRet = false; return(bRet); } #if UNITY_5_0 || UNITY_5_1 if (!anim.clip.legacy) { bRet = false; return(bRet); } #else SerializedObject serializedClip = new SerializedObject(anim.clip); SerializedProperty animationType = serializedClip.FindProperty("m_AnimationType"); if (animationType == null) { bRet = false; return(bRet); } if (animationType.intValue != (int)ModelImporterAnimationType.Legacy) { errorMsg = element.gameObject.name + "中的animation脚本没有clip动画或者此动画是animator的动画,animation的动画必须是Legacy的属性"; bRet = false; return(bRet); } #endif if (null == anim.GetComponent <Animation>()[anim.GetComponent <Animation>().clip.name]) { anim.AddClip(anim.clip, anim.GetComponent <Animation>().clip.name); } } return(bRet); }
public static SpecialEffectElement GetParentElem(SpecialEffectElement currElem) { if (null == currElem) { return(null); } return(currElem.gameObject.transform.parent.gameObject.GetComponent <SpecialEffectElement>()); }
public void Set(SpecialEffectEditProxy e, SpecialEffectElement elem) { for (int index = 0; index < e.RealSpe.elems.Count; index++) { if (UnityEngine.Object.ReferenceEquals(e.RealSpe.elems[index], elem)) { Set(e, index); break; } } }
private static bool FixChildrenElemStartTime(SpecialEffectElement currElem, List <SpecialEffectElement> childrenElem, float currStartTime) { bool bRet = true; if ( (null == currElem) || (null == childrenElem) ) { return(false); } currStartTime = (float)Math.Round((double)currStartTime, 2); if (currStartTime < 0) { return(false); } if (currElem == null) { return(false); } foreach (var item in childrenElem) { if (item != null) { float childStartTime = 0f; if (currStartTime >= item.startTime) { childStartTime = currStartTime; } else { childStartTime = (float)Math.Round((double)(currStartTime + GetElemDelayTime(item)), 2); } bRet = FixChildrenElemStartTime(item, GetChildrenElem(item), childStartTime); if (!bRet) { break; } item.startTime = childStartTime; } } return(bRet); }
public bool ShowSelectElemInspector(SpecialEffectElement elem) { bool bRet = false; for (int index = 0; index < realSpe.elems.Count; index++) { if (Object.ReferenceEquals(realSpe.elems[index], elem)) { bRet = ShowSelectElemInspector(index); break; } } return(bRet); }
public bool GetItemTimeInfo(SpecialEffectElement elem, ref float start, ref float length) { bool bRet = false; for (int index = 0; index < realSpe.elems.Count; index++) { if (Object.ReferenceEquals(realSpe.elems[index], elem)) { bRet = GetItemTimeInfo(index, ref start, ref length); break; } } return(bRet); }
public bool SetItemDelayTime(SpecialEffectElement elem, float startTime) { bool bRet = false; for (int index = 0; index < realSpe.elems.Count; index++) { if (Object.ReferenceEquals(realSpe.elems[index], elem)) { bRet = SetItemDelayTime(index, startTime); break; } } return(bRet); }
public bool SetItemStateInfo(SpecialEffectElement elem, bool loop) { bool bRet = false; for (int index = 0; index < realSpe.elems.Count; index++) { if (Object.ReferenceEquals(realSpe.elems[index], elem)) { bRet = SetItemStateInfo(index, loop); break; } } return(bRet); }
private static bool CheckChildrenPlayTime(float currPlayTime, SpecialEffectElement currElem) { bool bRet = true; if (null == currElem) { return(false); } currPlayTime = (float)Math.Round((double)currPlayTime, 2); if (currPlayTime < 0) { return(false); } if ( (currPlayTime <= currElem.playTime) ) { foreach (var item in GetChildrenElem(currElem)) { float parentEndTime = (float)Math.Round((double)(currElem.startTime + currPlayTime), 2); float childEndTime = (float)Math.Round((double)(item.startTime + item.playTime), 2); if (parentEndTime <= childEndTime) { float itemPlayTime = (float)Math.Round((double)(currPlayTime - GetElemDelayTime(item)), 2); if (itemPlayTime < 0f) { bRet = false; break; } bRet = CheckChildrenPlayTime(itemPlayTime, item); if (!bRet) { break; } } } } return(bRet); }
public static float GetElemDelayTime(SpecialEffectElement currElem) { if (null == currElem) { return(-1f); } SpecialEffectElement parent = GetParentElem(currElem); if (parent != null) { return((float)Math.Round(((double)currElem.startTime - (double)parent.startTime), 2)); } else { return((float)Math.Round((double)currElem.startTime, 2)); } }
public static List <SpecialEffectElement> GetChildrenElem(SpecialEffectElement currElem) { List <SpecialEffectElement> children = new List <SpecialEffectElement>(); if (null == currElem) { return(null); } for (int index = 0; index < currElem.gameObject.transform.childCount; index++) { SpecialEffectElement child = currElem.gameObject.transform.GetChild(index).gameObject.GetComponent <SpecialEffectElement>(); if (child != null) { children.Add(child); } } return(children); }
public static void FixElemStartTime(SpecialEffectElement currElem, float value) { if (null == currElem) { return; } value = (float)Math.Round((double)value, 2); if (value < 0) { return; } SpecialEffectElement parent = GetParentElem(currElem); if ( (parent != null) && (value < parent.startTime) ) { value = parent.startTime; } float detalTime = value - currElem.startTime; if (!CheckChildrenPlayTime(currElem.playTime - detalTime, currElem)) { return; } if (!FixChildrenElemStartTime(currElem, GetChildrenElem(currElem), value)) { return; } currElem.startTime = value; FixElemPlayTime(currElem, currElem.playTime - detalTime); }
public override bool Equals(object o) { if (o == null) { return(false); } if (o == this) { return(true); } if (GetType() != o.GetType()) { return(false); } SpecialEffectElement oe = o as SpecialEffectElement; if (startTime != oe.startTime) { return(false); } if (playTime != oe.playTime) { return(false); } if (isLoop != oe.isLoop) { return(false); } return(true); }
public override bool Equals(object o) { if (o == null) { return(false); } //自反 if (o == this) { return(true); } if (GetType() != o.GetType()) { return(false); } SpecialEffect otherSpe = o as SpecialEffect; if (totalTime != otherSpe.totalTime) { return(false); } if (style != otherSpe.style) { return(false); } if (playOnAwake != otherSpe.playOnAwake) { return(false); } if (!bindingTargetPath.Equals(otherSpe.bindingTargetPath)) { return(false); } //元素数不想等 if (elems.Count != otherSpe.elems.Count) { return(false); } //元素已经通过SpecialEffectEditorUtility按广度 //有先遍历添加,所以如果层级关系相同必然顺序一致 for (int i = 0; i < elems.Count; i++) { SpecialEffectElement e0 = elems[i]; SpecialEffectElement e1 = otherSpe.elems[i]; if (!e0.Equals(e1)) { return(false); } } return(true); }
public void ShowSingleElem(SerializedObject e, int count) { string errorMsg = string.Empty; if (null == e) { return; } SpecialEffectElement speElem = e.targetObject as SpecialEffectElement; if ( (null == speElem) || (null == speElem.gameObject) ) { return; } EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); EditorGUILayout.LabelField(speElem.gameObject.name, elemLableWidth); EditorGUILayout.EndHorizontal(); if (!SpecialEffectEditorUtility.IsSPEElementLegal(speElem, out errorMsg)) { EditorGUILayout.LabelField("特效元素无效", elemLableWidth); return; } EditorGUILayout.LabelField("起始时间(秒)", elemLableWidth); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("startTime"), noneTextLable, floatCtrlWidth); } else { EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); //EditorGUILayout.FloatField(e.FindProperty("startTime").floatValue, elemLableWidth); EditorGUILayout.LabelField(e.FindProperty("startTime").floatValue.ToString(), elemLableWidth); EditorGUILayout.EndHorizontal(); } EditorGUILayout.LabelField("循环", GUILayout.MaxWidth(30f)); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("isLoop"), noneTextLable, toggleWidth); } else { e.FindProperty("isLoop").boolValue = EditorGUILayout.Toggle(e.FindProperty("isLoop").boolValue, toggleWidth); } if (!e.FindProperty("isLoop").boolValue) { EditorGUILayout.LabelField("播放时长(秒)", elemLableWidth); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("playTime"), noneTextLable, floatCtrlWidth); } else { EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); EditorGUILayout.LabelField(e.FindProperty("playTime").floatValue.ToString(), elemLableWidth); EditorGUILayout.EndHorizontal(); } } }
public bool _CopyValues(SpecialEffectElement o) => false;
private static bool TryAddSpecialElemComponent(GameObject go) { if (go == null) { return(false); } SpecialEffect spe = go.GetComponent <SpecialEffect>(); //特效根节点 if (spe != null) { return(false); } SpecialEffectElement speElem = go.GetComponent <SpecialEffectElement>(); if (speElem != null) { //若绑定脚本非法先卸除,重新绑定 if (!IsSpecialEffectElementLegal(go)) { UnityEngine.Object.DestroyImmediate(speElem); speElem = null; } } if (speElem == null) { //ParticleSystem p = go.GetComponent<ParticleSystem>(); if (go.GetComponent <ParticleSystem>() != null) { go.AddComponent <SpecialEffectParticleSys>(); } else if (go.GetComponent <Animation>() != null) { go.AddComponent <SpecialEffectAnimation>(); } else if (go.GetComponent <Animator>() != null) { go.AddComponent <SpecialEffectAnimator>(); } else if (go.GetComponent <H3DTrailRender>() != null) { go.AddComponent <SpecialEffectTrailRenderer>(); } else { go.AddComponent <SpecialEffectElement>(); } } #if UNITY_5_0 || UNITY_5_1 Animation anim = go.GetComponent <Animation>(); if ( (anim != null) && (anim.clip != null) ) { anim.clip.legacy = true; } #endif return(true); }
private static bool IsSpecialEffectElementLegal(GameObject go) { if (go == null) { return(false); } SpecialEffect spe = go.GetComponent <SpecialEffect>(); //特效根节点 if (spe != null) { return(false); } SpecialEffectElement speElem = go.GetComponent <SpecialEffectElement>(); Type elemType = speElem.GetType(); if (elemType == typeof(SpecialEffectParticleSys)) { ParticleSystem particleSys = go.GetComponent <ParticleSystem>(); if (particleSys == null) { return(false); } } else if (elemType == typeof(SpecialEffectAnimation)) { Animation anim = go.GetComponent <Animation>(); if (anim == null) { return(false); } } else if (elemType == typeof(SpecialEffectAnimator)) { Animator anim = go.GetComponent <Animator>(); if (anim == null) { return(false); } } else if (elemType == typeof(SpecialEffectTrailRenderer)) { H3DTrailRender trail = go.GetComponent <H3DTrailRender>(); if (trail == null) { return(false); } } else { ParticleSystem particleSys = go.GetComponent <ParticleSystem>(); if (particleSys != null) { return(false); } Animation animation = go.GetComponent <Animation>(); if (animation != null) { return(false); } Animator animator = go.GetComponent <Animator>(); if (animator != null) { return(false); } } return(true); }
private static bool FixChildrenPlayTime(List <SpecialEffectElement> childrenElem, float currPlayTime, SpecialEffectElement currElem) { bool bRet = true; if ( (null == childrenElem) || (null == currElem) ) { return(false); } currPlayTime = (float)Math.Round((double)currPlayTime, 2); if (currPlayTime < 0) { return(false); } if (!CheckChildrenPlayTime(currPlayTime, currElem)) { return(false); } foreach (var item in childrenElem) { if (item != null) { float parentEndTime = (float)Math.Round((double)(currElem.startTime + currPlayTime), 2); float childEndTime = (float)Math.Round((double)(item.startTime + item.playTime), 2); if (parentEndTime <= childEndTime) { float itemPlayTime = (float)Math.Round((double)(currPlayTime - GetElemDelayTime(item)), 2); bRet = FixChildrenPlayTime(GetChildrenElem(item), itemPlayTime, item); if (!bRet) { break; } item.playTime = itemPlayTime; } } } return(bRet); }