public int GetAvailableEffectCount(string eftName) { ArrayList cache = EffectDic[eftName]; if (cache == null) { return(0); } int ret = 0; for (int i = 0; i < cache.Count; i++) { XffectComponent xftcomp = (XffectComponent)cache[i]; if (!XffectComponent.IsActive(xftcomp.gameObject)) { ret++; } } return(ret); }
//deactive the effect smoothly. public void StopEffect(string eftName) { List <XffectComponent> cache = EffectDic[eftName]; if (cache == null) { Debug.LogError(name + ": cache doesnt exist!"); return; } if (cache.Count > 1) { Debug.LogWarning("DeActive() only support one Xffect cache!"); } XffectComponent xft = cache[0]; if (!XffectComponent.IsActive(xft.gameObject)) { return; } xft.StopEmit(); }
void LateUpdate() { // if no collision needed, hide the colliders. if (!XffectComponent.IsActive(XCollisionTest1.gameObject) && !XffectComponent.IsActive(XCollisionTest2.gameObject)) { if (Colliders.gameObject == true) { foreach (Transform child in Colliders) { XffectComponent.SetActive(child.gameObject, false); } } XffectComponent.SetActive(Colliders.gameObject, false); } //auto deactive background m_checkTime += Time.deltaTime; if (m_checkTime > 5f) { XffectComponent.SetActive(BackgroundWallBottom.gameObject, false); } }
public XffectComponent GetEffect(string name) { if (!EffectDic.ContainsKey(name)) { Debug.LogError("there is no effect:" + name + " in effect cache!"); return(null); } ArrayList cache = EffectDic[name]; if (cache == null) { return(null); } foreach (XffectComponent xft in cache) { if (!XffectComponent.IsActive(xft.gameObject)) { return(xft); } } return(AddXffect(name)); }
//useful for only-one effect cache and the effect is looping. public void DeActiveEffect(string eftName) { ArrayList cache = EffectDic[eftName]; if (cache == null) { Debug.LogError(name + ": cache doesnt exist!"); return; } if (cache.Count > 1) { Debug.LogWarning("DeActive() only support one Xffect cache!"); } XffectComponent xft = (XffectComponent)cache[0]; if (!XffectComponent.IsActive(xft.gameObject)) { return; } xft.DeActive(); xft.Reset(); XffectComponent.SetActive(xft.gameObject, false); }
public override void OnInspectorGUI() { serializedObject.Update(); XEditor.BeginCommonArea("xffect main config", Script.gameObject.name, this, true); EditorGUILayout.Space(); XEditor.DrawToggle("update in editor?", "", EditView); //EditView.boolValue = EditorGUILayout.Toggle("update in editor:", EditView.boolValue,GUILayout.Height(40f)); if (EditView.boolValue == true) { if (!XffectComponent.IsActive(Script.gameObject)) { EditView.boolValue = false; Debug.Log("you need to activate the xffect object: " + Script.gameObject.name + " before updating it in editor."); } } if (EditView.boolValue) { Script.EnableEditView(); } else { Script.DisableEditView(); } if (EditView.boolValue) { if (GUILayout.Button("Reset")) { Script.ResetEditScene(); } } XEditor.DrawSeparator(); XEditor.DrawFloat("life(-1 means infinite):", "", LifeTime); XEditor.DrawToggle("ignore time scale?", "", IgnoreTimeScale); EditorGUILayout.Space(); XEditor.DrawFloat("scale:", "change this Xffect's scale", Scale); if (GUILayout.Button("Add Layer")) { GameObject layer = new GameObject(LayerName); EffectLayer efl = (EffectLayer)layer.AddComponent("EffectLayer"); layer.transform.parent = Selection.activeTransform; efl.transform.localPosition = Vector3.zero; //default to effect layer object. efl.ClientTransform = efl.transform; efl.GravityObject = efl.transform; efl.BombObject = efl.transform; efl.TurbulenceObject = efl.transform; efl.AirObject = efl.transform; efl.VortexObj = efl.transform; efl.DirCenter = efl.transform; efl.Material = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + DefaultMatPath, typeof(Material)) as Material; efl.gameObject.layer = Script.gameObject.layer; Selection.activeGameObject = layer; } if (GUILayout.Button("Add Event")) { GameObject obj = new GameObject("_Event"); XftEventComponent xevent = (XftEventComponent)obj.AddComponent("XftEventComponent"); xevent.transform.parent = Selection.activeTransform; xevent.transform.localPosition = Vector3.zero; xevent.RadialBlurShader = Shader.Find("Xffect/PP/radial_blur_new"); xevent.GlowCompositeShader = Shader.Find("Xffect/PP/glow_compose"); xevent.GlowDownSampleShader = Shader.Find("Xffect/PP/glow_downsample"); xevent.GlowBlurShader = Shader.Find("Xffect/PP/glow_conetap"); xevent.RadialBlurObj = xevent.transform; xevent.ColorInverseShader = Shader.Find("Xffect/PP/color_inverse"); xevent.GlowPerObjBlendShader = Shader.Find("Xffect/glow_per_obj/blend"); xevent.GlowPerObjReplacementShader = Shader.Find("Xffect/glow_per_obj/replacement"); xevent.gameObject.layer = Script.gameObject.layer; Selection.activeGameObject = obj; } EditorGUILayout.Space(); XEditor.EndXArea(); DrawInfos(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { XffectComponent ctarget = (XffectComponent)target; if (Application.isEditor && !EditorApplication.isPlaying) { EditorApplication.update = ctarget.Update; } EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.Separator(); ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime); EditorGUILayout.LabelField("[life -1 means infinite.]"); ctarget.IgnoreTimeScale = EditorGUILayout.Toggle("ignore time scale?", ctarget.IgnoreTimeScale); EditorGUILayout.Separator(); ctarget.Scale = EditorGUILayout.FloatField("scale:", ctarget.Scale); EditorGUILayout.Separator(); if (GUILayout.Button("Add Layer")) { GameObject layer = new GameObject(LayerName); EffectLayer efl = (EffectLayer)layer.AddComponent("EffectLayer"); layer.transform.parent = Selection.activeTransform; efl.transform.localPosition = Vector3.zero; //fixed 2012.6.25. default to effect layer object. efl.ClientTransform = efl.transform; efl.GravityObject = efl.transform; efl.BombObject = efl.transform; efl.TurbulenceObject = efl.transform; efl.AirObject = efl.transform; efl.VortexObj = efl.transform; efl.DirCenter = efl.transform; } if (GUILayout.Button("Add Event")) { GameObject layer = new GameObject("_Event"); XftEventComponent xevent = (XftEventComponent)layer.AddComponent("XftEventComponent"); xevent.transform.parent = Selection.activeTransform; xevent.transform.localPosition = Vector3.zero; xevent.RadialBlurShader = Shader.Find("Xffect/PP/radial_blur_new"); xevent.GlowCompositeShader = Shader.Find("Xffect/PP/glow_compose"); xevent.GlowDownSampleShader = Shader.Find("Xffect/PP/glow_downsample"); xevent.GlowBlurShader = Shader.Find("Xffect/PP/glow_conetap"); xevent.RadialBlurObj = xevent.transform; xevent.ColorInverseShader = Shader.Find("Xffect/PP/color_inverse"); } EditorGUILayout.Separator(); ctarget.EditView = EditorGUILayout.Toggle("update in editor?", ctarget.EditView); //prevent asset inspector to update. if (ctarget.EditView == true) { if (!XffectComponent.IsActive(ctarget.gameObject)) { ctarget.EditView = false; Debug.Log("you should activate the xffect object: " + ctarget.gameObject.name + " before updating it in editor."); } } if (ctarget.EditView) { ctarget.EnableEditView(); } else { ctarget.DisableEditView(); } if (ctarget.EditView) { if (GUILayout.Button("Reset Editor Xffect")) { ctarget.ResetEditScene(); } } EditorGUILayout.EndVertical(); if (GUI.changed) { EditorUtility.SetDirty(target); } }