public void ApplyToUnityParticleSystem(UnityEngine.ParticleSystem ups, ParticleSystem ps) { var sizeModule = ups.sizeOverLifetime; sizeModule.enabled = true; sizeModule.separateAxes = true; var curvX = new UnityEngine.AnimationCurve(); var curvY = new UnityEngine.AnimationCurve(); var curvZ = new UnityEngine.AnimationCurve(); //重复的key第二次不会添加 for (int i = keyFrameLifeTime.Count - 1; i >= 0; --i) { curvX.AddKey(keyFrameLifeTime[i], sizeX[i]); curvY.AddKey(keyFrameLifeTime[i], sizeY[i]); curvZ.AddKey(keyFrameLifeTime[i], sizeZ[i]); //curvZ.AddKey(keyFrameLifeTime[i], sizeZ[i] <= 0.001f ? 1.0f:sizeZ[i] ); } CurveExtended.CurveExtension.ForceUpdateAllLinearTangents(curvX); CurveExtended.CurveExtension.ForceUpdateAllLinearTangents(curvY); CurveExtended.CurveExtension.ForceUpdateAllLinearTangents(curvZ); sizeModule.x = new UnityEngine.ParticleSystem.MinMaxCurve(maxXYZ[0], curvX); //exchange yz if (maxXYZ[2] <= 0.001f) { sizeModule.y = new UnityEngine.ParticleSystem.MinMaxCurve(maxXYZ[1], curvY); } else { sizeModule.y = new UnityEngine.ParticleSystem.MinMaxCurve(maxXYZ[2], curvZ); } sizeModule.z = new UnityEngine.ParticleSystem.MinMaxCurve(maxXYZ[1], curvY); }
static public int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.AnimationCurve o; if (argc == 2) { UnityEngine.Keyframe[] a1; checkParams(l, 2, out a1); o = new UnityEngine.AnimationCurve(a1); pushValue(l, o); return(1); } else if (argc == 1) { o = new UnityEngine.AnimationCurve(); pushValue(l, o); return(1); } LuaDLL.luaL_error(l, "New object failed."); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
// fields // properties static void AnimationCurve_keys(JSVCall vc) { if (vc.bGet) { UnityEngine.AnimationCurve _this = (UnityEngine.AnimationCurve)vc.csObj; var result = _this.keys; var arrRet = result; for (int i = 0; arrRet != null && i < arrRet.Length; i++) { JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]); JSApi.moveSaveID2Arr(i); } JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true); } else { UnityEngine.Keyframe[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.Keyframe[]>(() => { int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg); int length = JSApi.getArrayLength(jsObjID); var ret = new UnityEngine.Keyframe[length]; for (var i = 0; i < length; i++) { JSApi.getElement(jsObjID, i); ret[i] = (UnityEngine.Keyframe)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove); } return(ret); }); UnityEngine.AnimationCurve _this = (UnityEngine.AnimationCurve)vc.csObj; _this.keys = arg0; } }
public static MeshData GenerateTerrainMesh(float[,] heightMap, float heightMultiplier, AnimationCurve _heightCurve, int levelOfDetail) { AnimationCurve heightCurve = new AnimationCurve (_heightCurve.keys); int meshSimplificationIncrement = (levelOfDetail == 0)?1:levelOfDetail * 2; int borderedSize = heightMap.GetLength (0); int meshSize = borderedSize - 2*meshSimplificationIncrement; int meshSizeUnsimplified = borderedSize - 2; float topLeftX = (meshSizeUnsimplified - 1) / -2f; float topLeftZ = (meshSizeUnsimplified - 1) / 2f; int verticesPerLine = (meshSize - 1) / meshSimplificationIncrement + 1; MeshData meshData = new MeshData (verticesPerLine); int[,] vertexIndicesMap = new int[borderedSize,borderedSize]; int meshVertexIndex = 0; int borderVertexIndex = -1; for (int y = 0; y < borderedSize; y += meshSimplificationIncrement) { for (int x = 0; x < borderedSize; x += meshSimplificationIncrement) { bool isBorderVertex = y == 0 || y == borderedSize - 1 || x == 0 || x == borderedSize - 1; if (isBorderVertex) { vertexIndicesMap [x, y] = borderVertexIndex; borderVertexIndex--; } else { vertexIndicesMap [x, y] = meshVertexIndex; meshVertexIndex++; } } } for (int y = 0; y < borderedSize; y += meshSimplificationIncrement) { for (int x = 0; x < borderedSize; x += meshSimplificationIncrement) { int vertexIndex = vertexIndicesMap [x, y]; Vector2 percent = new Vector2 ((x-meshSimplificationIncrement) / (float)meshSize, (y-meshSimplificationIncrement) / (float)meshSize); float height = heightCurve.Evaluate (heightMap [x, y]) * heightMultiplier; Vector3 vertexPosition = new Vector3 (topLeftX + percent.x * meshSizeUnsimplified, height, topLeftZ - percent.y * meshSizeUnsimplified); meshData.AddVertex (vertexPosition, percent, vertexIndex); if (x < borderedSize - 1 && y < borderedSize - 1) { int a = vertexIndicesMap [x, y]; int b = vertexIndicesMap [x + meshSimplificationIncrement, y]; int c = vertexIndicesMap [x, y + meshSimplificationIncrement]; int d = vertexIndicesMap [x + meshSimplificationIncrement, y + meshSimplificationIncrement]; meshData.AddTriangle (a,d,c); meshData.AddTriangle (d,a,b); } vertexIndex++; } } return meshData; }
public void EqualSource() { Assert.AreEqual(originClip.frameRate, clip.FrameRate); Assert.AreEqual(originClip.wrapMode, (UnityEngine.WrapMode)clip.WrapMode); EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(originClip); Assert.AreEqual(clip.BindingsLength, bindings.Length); for (int i = 0; i < bindings.Length; i++) { Schema.CurveBinding bind = clip.GetBindings(i); Assert.AreEqual(bind.PropertyName, bindings[i].propertyName); Assert.AreEqual(bind.Path, bindings[i].path); Assert.AreEqual(bind.Type, bindings[i].type.FullName); Schema.AnimationCurve curv = bind.GetCurve(new Schema.AnimationCurve()); UnityEngine.AnimationCurve originCurve = AnimationUtility.GetEditorCurve(originClip, bindings[i]); Assert.AreEqual(curv.PreWrapMode, (Schema.WrapMode)originCurve.preWrapMode); Assert.AreEqual(curv.PostWrapMode, (Schema.WrapMode)originCurve.postWrapMode); Assert.AreEqual(curv.KeyFramesLength, originCurve.keys.Length); for (int j = 0; j < curv.KeyFramesLength; j++) { Schema.KeyFrame keyFrame = curv.GetKeyFrames(j); UnityEngine.Keyframe originKeyframe = originCurve.keys[j]; Assert.AreEqual(keyFrame.InTangent, originKeyframe.inTangent); Assert.AreEqual(keyFrame.OutTangent, originKeyframe.outTangent); Assert.AreEqual(keyFrame.TangentMode, originKeyframe.tangentMode); Assert.AreEqual(keyFrame.Time, originKeyframe.time); Assert.AreEqual(keyFrame.Value, originKeyframe.value); } } }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = rectVariable.IsNone ? 0f : rectVariable.Value.x; fromFloats[1] = rectVariable.IsNone ? 0f : rectVariable.Value.y; fromFloats[2] = rectVariable.IsNone ? 0f : rectVariable.Value.width; fromFloats[3] = rectVariable.IsNone ? 0f : rectVariable.Value.height; curves = new AnimationCurve[4]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveW.curve; curves[3] = curveH.curve; calculations = new Calculation[4]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationW; calculations[3] = calculationH; Init(); if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
void Start() { _texture = new Texture2D(Width, Height, TextureFormat.ARGB32, false); _texture.Apply(false, false); if (_movieCapture) { _movieCapture.SetSourceTexture(_texture); } _pixels = new Color32[Width*Height]; _palette = new Color32[PaletteSize]; Keyframe[] keysR = { new Keyframe(0f, 0f), new Keyframe(0.25f, 1f), new Keyframe(1f, 0f) }; Keyframe[] keysG = { new Keyframe(0f, 1f), new Keyframe(0.5f, 0f), new Keyframe(1f, 1f) }; Keyframe[] keysB = { new Keyframe(0f, 1f), new Keyframe(0.75f, 0f), new Keyframe(1f, 0f) }; AnimationCurve curveR = new AnimationCurve(keysR); AnimationCurve curveG = new AnimationCurve(keysG); AnimationCurve curveB = new AnimationCurve(keysB); for (int i = 0; i < PaletteSize; i++) { float r = curveR.Evaluate((float)i / (float)PaletteSize); float g = curveG.Evaluate((float)i / (float)PaletteSize); float b = curveB.Evaluate((float)i / (float)PaletteSize); _palette[i] = new Color32((byte)(r * 255.0f), (byte)(g * 255.0f), (byte)(b * 255.0f), (byte)(b * 255.0f)); } }
void Start() { // Initialize the time value to the end time of the animation to prevent it from playing right away _timeValue = flashDuration; _flashCurve = new AnimationCurve (new Keyframe (0, 0), new Keyframe (flashDuration * 0.15F, 1), new Keyframe (flashDuration, 0)); }
private void AddPoints(float minTime, float maxTime) { AnimationCurve quaternionX = this.quaternionX; if (quaternionX.length == 0) { quaternionX = this.eulerX; } if (quaternionX.length != 0) { Keyframe keyframe = quaternionX[0]; if (keyframe.time >= minTime) { Keyframe keyframe2 = quaternionX[0]; Vector3 values = this.GetValues(keyframe2.time, true); this.points[this.rangeStart] = values; Keyframe keyframe3 = quaternionX[0]; this.points[keyframe3.time] = values; } Keyframe keyframe4 = quaternionX[quaternionX.length - 1]; if (keyframe4.time <= maxTime) { Keyframe keyframe5 = quaternionX[quaternionX.length - 1]; Vector3 vector2 = this.GetValues(keyframe5.time, true); Keyframe keyframe6 = quaternionX[quaternionX.length - 1]; this.points[keyframe6.time] = vector2; this.points[this.rangeEnd] = vector2; } for (int i = 0; i < (quaternionX.length - 1); i++) { Keyframe keyframe7 = quaternionX[i + 1]; if (keyframe7.time >= minTime) { Keyframe keyframe8 = quaternionX[i]; if (keyframe8.time <= maxTime) { Keyframe keyframe9 = quaternionX[i]; float time = keyframe9.time; this.points[time] = this.GetValues(time, true); for (float j = 1f; j <= 20f; j++) { Keyframe keyframe10 = quaternionX[i]; Keyframe keyframe11 = quaternionX[i + 1]; time = Mathf.Lerp(keyframe10.time, keyframe11.time, (j - 0.001f) / 40f); this.points[time] = this.GetValues(time, false); } Keyframe keyframe12 = quaternionX[i + 1]; time = keyframe12.time; this.points[time] = this.GetValues(time, true); for (float k = 1f; k <= 20f; k++) { Keyframe keyframe13 = quaternionX[i]; Keyframe keyframe14 = quaternionX[i + 1]; time = Mathf.Lerp(keyframe13.time, keyframe14.time, 1f - ((k - 0.001f) / 40f)); this.points[time] = this.GetValues(time, false); } } } } } }
public static MeshData GenerateTerrainMesh(float[,] heightMap, float heightMultiplier, AnimationCurve _heightCurve, int levelOfDetail) { AnimationCurve heightCurve = new AnimationCurve (_heightCurve.keys); int width = heightMap.GetLength (0); int height = heightMap.GetLength (1); float topLeftX = (width - 1) / -2f; float topLeftZ = (height - 1) / 2f; int meshSimplificationIncrement = (levelOfDetail == 0)?1:levelOfDetail * 2; int verticesPerLine = (width - 1) / meshSimplificationIncrement + 1; MeshData meshData = new MeshData (verticesPerLine, verticesPerLine); int vertexIndex = 0; for (int y = 0; y < height; y += meshSimplificationIncrement) { for (int x = 0; x < width; x += meshSimplificationIncrement) { meshData.vertices [vertexIndex] = new Vector3 (topLeftX + x, heightCurve.Evaluate (heightMap [x, y]) * heightMultiplier, topLeftZ - y); meshData.uvs [vertexIndex] = new Vector2 (x / (float)width, y / (float)height); if (x < width - 1 && y < height - 1) { meshData.AddTriangle (vertexIndex, vertexIndex + verticesPerLine + 1, vertexIndex + verticesPerLine); meshData.AddTriangle (vertexIndex + verticesPerLine + 1, vertexIndex, vertexIndex + 1); } vertexIndex++; } } return meshData; }
public static int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.AnimationCurve o; if(argc==2){ UnityEngine.Keyframe[] a1; checkValueParams(l,2,out a1); o=new UnityEngine.AnimationCurve(a1); pushValue(l,true); pushValue(l,o); return 2; } else if(argc==1){ o=new UnityEngine.AnimationCurve(); pushValue(l,true); pushValue(l,o); return 2; } return error(l,"New object failed."); } catch(Exception e) { return error(l,e); } }
static void AnimationCurve_length(JSVCall vc) { UnityEngine.AnimationCurve _this = (UnityEngine.AnimationCurve)vc.csObj; var result = _this.length; JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result)); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[3]; fromFloats = new float[3]; fromFloats[0] = vectorVariable.IsNone ? 0f : vectorVariable.Value.x; fromFloats[1] = vectorVariable.IsNone ? 0f : vectorVariable.Value.y; fromFloats[2] = vectorVariable.IsNone ? 0f : vectorVariable.Value.z; curves = new AnimationCurve[3]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveZ.curve; calculations = new Calculation[3]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationZ; Init(); // Set initial value if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
void SetLoupiotteAproach() { AnimationClip clip = new AnimationClip(); Keyframe[] xValues = new Keyframe[5]; Keyframe[] yValues = new Keyframe[5]; Keyframe[] zValues = new Keyframe[5]; Keyframe[] stateValues = new Keyframe[5]; for (int i = 0; i<5; i++) { xValues[i] = new Keyframe(i * 3.0f, i < 4 ? Random.Range(-20.0f / (2 * i + 1), 20.0f / (2 * i + 1)) : xReference); zValues[i] = new Keyframe(i * 3.0f, i < 4 ? Random.Range(-20.0f / (2 * i + 1), 20.0f / (2 * i + 1)) : zReference); stateValues[i] = new Keyframe(i * 3.0f, i < 4 ? 0.0f : 1.0f); } yValues[0] = new Keyframe(0.0f, 50.0f); yValues[1] = new Keyframe(3.0f, 35.0f); yValues[2] = new Keyframe(6.0f, 25.0f); yValues[3] = new Keyframe(9.0f, 15.0f); yValues[4] = new Keyframe(12.0f, yReference); AnimationCurve xCurve = new AnimationCurve(xValues); AnimationCurve yCurve = new AnimationCurve(yValues); AnimationCurve zCurve = new AnimationCurve(zValues); AnimationCurve stateCurve = new AnimationCurve(stateValues); clip.legacy = true; clip.SetCurve("", typeof(Loupiotte), "positionToPlayer.x", xCurve); clip.SetCurve("", typeof(Loupiotte), "positionToPlayer.y", yCurve); clip.SetCurve("", typeof(Loupiotte), "positionToPlayer.z", zCurve); clip.SetCurve("", typeof(Loupiotte), "state", stateCurve); anim.AddClip(clip, "Approche"); }
public static void UpdateTangentsFromMode(AnimationCurve curve) { for (int i = 0; i < curve.length; i++) { CurveUtility.UpdateTangentsFromMode(curve, i); } }
/// <summary> /// Write the specified value using the writer. /// </summary> /// <param name="value">Value.</param> /// <param name="writer">Writer.</param> public override void Write(object value, ISaveGameWriter writer) { UnityEngine.AnimationCurve animationCurve = (UnityEngine.AnimationCurve)value; writer.WriteProperty("keys", animationCurve.keys); writer.WriteProperty("preWrapMode", animationCurve.preWrapMode); writer.WriteProperty("postWrapMode", animationCurve.postWrapMode); }
void OnEnable() { // This function is called when the object is loaded (used for similar reasons to MonoBehaviour.Reset) id = GUID.Create(id); if (attribDataFabs == null) attribDataFabs = new List<RPGAttributeData>(0); if (levelCurve == null) levelCurve = AnimationCurve.Linear(1, 1, maxXP, maxLevel); if (xpAttribId == null) xpAttribId = new GUID(); }
public AttractionForceAffector(AnimationCurve curve, Vector3 pos, EffectNode node) : base(node) { AttractionCurve = curve; Position = pos; UseCurve = true; }
public void TestBackwardCurveWithCache(float timeStep, int keyframeCount) { var animCurve = new UnityEngine.AnimationCurve(); for (var i = 0; i < keyframeCount; ++i) { animCurve.AddKey(new UnityEngine.Keyframe(i, i * timeStep, Mathf.Infinity, Mathf.Infinity)); } var curveBlob = animCurve.ToAnimationCurveBlobAssetRef(); var curve = new Unity.Animation.AnimationCurve(); curve.SetAnimationCurveBlobAssetRef(curveBlob); Measure.Method(() => { // The longer the time step, the more the cache gets reused. for (var t = keyframeCount * timeStep; t >= 0.0f; t -= 0.1f) { AnimationCurveEvaluator.Evaluate(t, ref curve); } }) .WarmupCount(1) .MeasurementCount(100) .Run(); curveBlob.Dispose(); }
// Update is called once per frame void Update() { if (!IsLoad) { if (staticscript .smallwaveManager == null) return; ScaleY = staticscript.smallwaveManager.XPos; IsLoad = true; } float Pos = staticscript.rhythmManager.FixedRhythm.Pos; Vector3 p = pos; Vector3 s = scale; Quaternion q = rote; //if (rhythmManager.IsSlow) // speed = 0.5f; //p.y -= XValue / 2; //p.y += pos.y + ScaleX.Evaluate(Pos) * speed * XValue / 3.2f; //s.y += scale.y + ScaleX.Evaluate(Pos) * speed * XValue * 4; int deg = (int)(ScaleY.Evaluate(Pos * 2) * XValue) * angle; //Quaternion qhoge = Quaternion.AngleAxis(deg, this.transform.right); Quaternion qhoge = Quaternion.AngleAxis(deg, this.transform.forward); q = rote * qhoge; this.transform.localPosition = p; this.transform.localScale = s; this.transform.localRotation = q; }
public static AnimationCurve String2AnimationCurve(string curveString, char sp = ';') { UnityEngine.AnimationCurve curve = new UnityEngine.AnimationCurve(); if (string.IsNullOrEmpty(curveString)) { return(curve); } try { var curveValues = curveString.Split(new char[] { sp }); foreach (var keyFrameValue in curveValues) { Keyframe keyFrame = new Keyframe(); if (!String2KeyFrame(keyFrameValue, out keyFrame)) { ggc.Foundation.Log.LogErrorMsg("Wrong KeyFrame Value:" + keyFrameValue + " in AnimationCurve Config: " + curveString); continue; } curve.AddKey(keyFrame); } return(curve); } catch { ggc.Foundation.Log.LogErrorMsg("Wrong AnimationCurve Value: " + curveString); return(curve); } }
void Start() { moves[0] = new Vector3( 0f, 1f, 0f); moves[1] = new Vector3(-3f, 1f, 5f); moves[2] = new Vector3( 3f, 1f, 5f); moves[3] = new Vector3(-3f, 1f, -3f); moves[4] = new Vector3( 3f, 1f, -3f); for(int i=0;i<5;i++){ cubes[i] = GameObject.Find ("BoardCube"+i); Vector3 move = cubes[i].transform.position; AnimationClip clip = new AnimationClip(); Keyframe[] keysX = new Keyframe[2]; keysX[0] = new Keyframe( 0f, move.x-3); keysX[1] = new Keyframe(i+1f, move.x+3); AnimationCurve curveX = new AnimationCurve(keysX); clip.SetCurve("", typeof(Transform), "localPosition.x", curveX); clip.wrapMode = WrapMode.PingPong; Keyframe[] keysY = new Keyframe[2]; keysY[0] = new Keyframe( 0f, move.y); keysY[1] = new Keyframe(i+1f, move.y); AnimationCurve curveY = new AnimationCurve(keysY); clip.SetCurve("", typeof(Transform), "localPosition.y", curveY); Keyframe[] keysZ = new Keyframe[2]; keysZ[0] = new Keyframe( 0f, move.z); keysZ[1] = new Keyframe(i+1f, move.z); AnimationCurve curveZ = new AnimationCurve(keysZ); clip.SetCurve("", typeof(Transform), "localPosition.z", curveZ); cubes[i].animation.AddClip(clip, "clip1"); cubes[i].animation.Play("clip1"); } }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[3]; fromFloats = new float[3]; fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value.x; fromFloats[1] = fromValue.IsNone ? 0f : fromValue.Value.y; fromFloats[2] = fromValue.IsNone ? 0f : fromValue.Value.z; toFloats = new float[3]; toFloats[0] = toValue.IsNone ? 0f : toValue.Value.x; toFloats[1] = toValue.IsNone ? 0f : toValue.Value.y; toFloats[2] = toValue.IsNone ? 0f : toValue.Value.z; curves = new AnimationCurve[3]; curves[0] = curveX.curve; curves[1] = curveY.curve; curves[2] = curveZ.curve; calculations = new Calculation[3]; calculations[0] = calculationX; calculations[1] = calculationY; calculations[2] = calculationZ; //call Init after you have initialized curves array Init(); }
public TreeGroup() { Keyframe[] keys = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.distributionCurve = new AnimationCurve(keys); this.distributionNodes = 5; this.distributionTwirl = 0f; this.distributionPitch = 0f; Keyframe[] keyframeArray2 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.distributionPitchCurve = new AnimationCurve(keyframeArray2); this.distributionScale = 1f; Keyframe[] keyframeArray3 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 0.3f) }; this.distributionScaleCurve = new AnimationCurve(keyframeArray3); this.showAnimationProps = true; this.animationPrimary = 0.5f; this.animationSecondary = 0.5f; this.animationEdge = 1f; this.visible = true; this.lockFlags = 0; this.nodeIDs = new int[0]; this.parentGroupID = -1; this.childGroupIDs = new int[0]; this.nodes = new List<TreeNode>(); this.parentGroup = null; this.childGroups = new List<TreeGroup>(); }
public void FadeOut(AnimationCurve curve, float fadeTime) { this.curve = curve; this.fadeTime = fadeTime; isFading = true; }
void Awake () { if (GameObject.FindGameObjectsWithTag ("SoundManager").Length >= 2) { Destroy (gameObject); return; } curveRate = 0.0f; nowVolume = 1.0f; updateCurve = null; DontDestroyOnLoad (this.gameObject); feed_inCurve = feed_inCurveSetting; feed_outCurve = feed_outCurveSetting; //Dictionaryに追加する bgmDictionary = new Dictionary<BGM_NAME, BGMs>(); for (int i = 0; i < bgmParameter.Length; i++) { bgmDictionary [bgmParameter [i].bgmName] = bgmParameter [i]; } seDictionary = new Dictionary<SE_NAME, SEs>(); for (int i = 0; i < seParameter.Length; i++) { seDictionary [seParameter [i].seName] = seParameter [i]; } gameObject.AddComponent<AudioSource> (); myObj = gameObject; nowBgmEnum = BGM_NAME.TITLE; SetVolume (1.0f); }
public NormalCurveRenderer(AnimationCurve curve) { this.m_Curve = curve; if (this.m_Curve != null) return; this.m_Curve = new AnimationCurve(); }
static public int AddKey(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.Keyframe a1; checkType(l, 2, out a1); var ret = self.AddKey(a1); pushValue(l, ret); return(1); } else if (argc == 3) { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); System.Single a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); var ret = self.AddKey(a1, a2); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public JetAffector(float mag, MAGTYPE type, AnimationCurve curve,EffectNode node) : base(node, AFFECTORTYPE.JetAffector) { Mag = mag; MType = type; MagCurve = curve; }
public ResourceObject Parse(ByteBuffer bb) { UnityEngine.AnimationClip clip = new UnityEngine.AnimationClip(); Schema.AnimationClip _clip = Schema.AnimationClip.GetRootAsAnimationClip(bb); clip.frameRate = _clip.FrameRate; clip.wrapMode = (UnityEngine.WrapMode)_clip.WrapMode; clip.legacy = true; for (int i = 0; i < _clip.BindingsLength; i++) { Schema.CurveBinding bind = _clip.GetBindings(i); Schema.AnimationCurve _curve = bind.Curve; UnityEngine.AnimationCurve curve = new UnityEngine.AnimationCurve(); for (int j = 0; j < _curve.KeyFramesLength; j++) { Schema.KeyFrame _kf = _curve.GetKeyFrames(j); UnityEngine.Keyframe kf = new UnityEngine.Keyframe(_kf.Time, _kf.Value, _kf.InTangent, _kf.OutTangent); kf.tangentMode = _kf.TangentMode; curve.AddKey(kf); } curve.preWrapMode = (UnityEngine.WrapMode)_curve.PreWrapMode; curve.postWrapMode = (UnityEngine.WrapMode)_curve.PostWrapMode; var assembly = Assembly.Load("UnityEngine"); Type type = assembly.GetType(bind.Type); clip.SetCurve(bind.Path, type, bind.PropertyName, curve); } return(new ResourceObjectSingle(clip)); }
public static void createAnimation() { GameObject go = GameObject.Find(GAME_OBJECT_NAME); if (go != null) removeGameObjectAndComponents(go); Animator animator; go = createGameObjects(out animator); AnimationClip animationClip = new AnimationClip(); AnimationUtility.SetAnimationType(animationClip, ModelImporterAnimationType.Generic); AnimationCurve activeCurve = new AnimationCurve(); AnimationCurve positionLineCurve = new AnimationCurve(); AnimationCurve positionSmoothCurve = new AnimationCurve(); for (int i = 0; i < stepValues.Length; i++) { float time = stepTime * i; activeCurve .AddKey(KeyframeUtil.GetNew(time, stepValues[i] , TangentMode.Stepped)); positionLineCurve .AddKey(KeyframeUtil.GetNew(time, stepValues[i] + 2, TangentMode.Linear)); positionSmoothCurve.AddKey(KeyframeUtil.GetNew(time, stepValues[i] - 2, TangentMode.Smooth)); } //this will be linear curve, so need to update tangents (should be after keyframes assignments) positionLineCurve.UpdateAllLinearTangents(); animationClip.SetCurve(CUBE1_NAME, typeof(GameObject),"m_IsActive", activeCurve); animationClip.SetCurve(CUBE2_NAME, typeof(Transform),"localPosition.x", positionLineCurve); animationClip.SetCurve(CUBE2_NAME, typeof(Transform),"localPosition.y", positionSmoothCurve); AssetDatabase.CreateAsset(animationClip, ANIMATION_CLIP_PATH); AssetDatabase.SaveAssets(); AddClipToAnimatorComponent(go, animator, animationClip); }
// Use this for initialization void Start() { m_InitialPosition = gameObject.transform.localPosition; m_RelPosition.Set(0, 0, 0); m_Translations = new Vector3[3]; m_Translations[0].Set(m_Speed, 0, 0); m_Translations[1].Set(0, m_Speed, 0); m_Translations[2].Set(0, 0, m_Speed); gameObject.AddComponent<Animation>(); gameObject.animation.animatePhysics = true; m_Forward = new AnimationClip(); var curvex = new AnimationCurve(); var curvey = new AnimationCurve(); var curvez = new AnimationCurve(); var minpos = m_InitialPosition+m_MinIncrement; var maxpos = m_InitialPosition-m_MaxIncrement; float dist = (minpos-maxpos).magnitude; m_MaxTime = dist/m_Speed; curvex.AddKey(0f, minpos.x); curvex.AddKey(dist/m_Speed, maxpos.x); curvey.AddKey(0f, minpos.y); curvey.AddKey(dist/m_Speed, maxpos.y); curvez.AddKey(0f, minpos.z); curvez.AddKey(dist/m_Speed, maxpos.z); m_Forward.wrapMode = WrapMode.ClampForever; m_Forward.SetCurve("", typeof(Transform), "localPosition.x", curvex); m_Forward.SetCurve("", typeof(Transform), "localPosition.y", curvey); m_Forward.SetCurve("", typeof(Transform), "localPosition.z", curvez); this.animation.AddClip(m_Forward, "Forward"); this.animation.Play("Forward"); m_ForwardState = this.animation["Forward"]; }
public void ApplyToUnityParticleSystem(UnityEngine.ParticleSystem ups, ParticleSystem ps) { var textureSheetAnimationModule = ups.textureSheetAnimation; textureSheetAnimationModule.enabled = true; textureSheetAnimationModule.numTilesX = (int)columns; textureSheetAnimationModule.numTilesY = (int)rows; textureSheetAnimationModule.animation = ParticleSystemAnimationType.WholeSheet; if (randomFrame) { textureSheetAnimationModule.frameOverTime = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 1.0f); } else if (lifeDuration) { var curve = new UnityEngine.AnimationCurve(); curve.AddKey(new Keyframe(0.0f, 0.0f)); curve.AddKey(new Keyframe(1.0f, 1.0f)); CurveExtended.CurveExtension.ForceUpdateAllLinearTangents(curve); textureSheetAnimationModule.frameOverTime = new UnityEngine.ParticleSystem.MinMaxCurve(1.0f, curve); textureSheetAnimationModule.cycleCount = 1; } else { var curve = new UnityEngine.AnimationCurve(); curve.AddKey(new Keyframe(0.0f, 0.0f)); curve.AddKey(new Keyframe(1.0f, 1.0f)); CurveExtended.CurveExtension.ForceUpdateAllLinearTangents(curve); textureSheetAnimationModule.frameOverTime = new UnityEngine.ParticleSystem.MinMaxCurve(1.0f, curve); textureSheetAnimationModule.cycleCount = 1; } }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = colorVariable.IsNone ? 0f : colorVariable.Value.r; fromFloats[1] = colorVariable.IsNone ? 0f : colorVariable.Value.g; fromFloats[2] = colorVariable.IsNone ? 0f : colorVariable.Value.b; fromFloats[3] = colorVariable.IsNone ? 0f : colorVariable.Value.a; curves = new AnimationCurve[4]; curves[0] = curveR.curve; curves[1] = curveG.curve; curves[2] = curveB.curve; curves[3] = curveA.curve; calculations = new Calculation[4]; calculations[0] = calculationR; calculations[1] = calculationG; calculations[2] = calculationB; calculations[3] = calculationA; Init(); // Set initial value if (Math.Abs(delay.Value) < 0.01f) { UpdateVariableValue(); } }
void OnDeathStart(DynamicScreen loser, float loseTime, AnimationCurve loseRate) { if (loser.screenIndex == instanceIndex) { StartCoroutine(DeathRoutine(loseTime)); } }
public static AnimationCurve CreateLineraCurve( float[] values, float[] times ) { D.Assert( values != null && times != null, "Param == null" ); D.Assert( values.Length == times.Length, "Size not same" ); AnimationCurve result; Keyframe[] ks = new Keyframe[values.Length]; for( int i = 0; i < values.Length; i ++ ) { float inTgt; float outTgt; if ( i == 0){ inTgt = 0; }else{ inTgt = (values[ i ] - values[i-1])/(times[i] - times[i-1]); } if ( i == values.Length -1){ outTgt = 0; }else{ outTgt = (values[ i+1 ] - values[i])/(times[i+1] - times[i]); } ks[ i ] = new Keyframe( times[ i ], values[ i ], inTgt, outTgt ); } result = new AnimationCurve( ks ); return result; }
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { Keyframe[] keyframes; AnimationCurve curve=new AnimationCurve(); // curve.preWrapMode=(WrapMode)info.GetValue("preWrapMode",typeof(WrapMode)); // curve.postWrapMode=(WrapMode)info.GetValue("postWrapMode",typeof(WrapMode)); int numKeys=info.GetInt32("keysn"); keyframes=new Keyframe[numKeys]; Keyframe keyframeCurrent; for (int i=0; i<numKeys; i++) { keyframeCurrent=keyframes[i]=new Keyframe(info.GetSingle("keyt"+i), info.GetSingle("keyv"+i)); keyframeCurrent.tangentMode=info.GetInt32("keymod"+i); keyframeCurrent.inTangent=info.GetSingle("keyin"+i); keyframeCurrent.outTangent=info.GetSingle("keyout"+i); } curve.keys = keyframes; // don't know how to make connection between AnimaitonCurver and Keyframes surrogate // AnimationCurve surrogate keys are constructed before thoose in Keyframe surrogate resulting in 0,0 Keyframes //return new AnimationCurve((Keyframe[])info.GetValue ("keys", typeof(Keyframe[]))); return curve; }
public override object Read <T>(ES3Reader reader) { var instance = new UnityEngine.AnimationCurve(); ReadInto <T>(reader, instance); return(instance); }
public override void OnEnter() { base.OnEnter(); finishInNextStep = false; resultFloats = new float[4]; fromFloats = new float[4]; fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value.r; fromFloats[1] = fromValue.IsNone ? 0f : fromValue.Value.g; fromFloats[2] = fromValue.IsNone ? 0f : fromValue.Value.b; fromFloats[3] = fromValue.IsNone ? 0f : fromValue.Value.a; toFloats = new float[4]; toFloats[0] = toValue.IsNone ? 0f : toValue.Value.r; toFloats[1] = toValue.IsNone ? 0f : toValue.Value.g; toFloats[2] = toValue.IsNone ? 0f : toValue.Value.b; toFloats[3] = toValue.IsNone ? 0f : toValue.Value.a; curves = new AnimationCurve[4]; curves[0] = curveR.curve; curves[1] = curveG.curve; curves[2] = curveB.curve; curves[3] = curveA.curve; calculations = new Calculation[4]; calculations[0] = calculationR; calculations[1] = calculationG; calculations[2] = calculationB; calculations[3] = calculationA; //call Init after you have initialized curves array Init(); }
public TreeGroupBranch() { Keyframe[] keys = new Keyframe[] { new Keyframe(0f, 1f, -1f, -1f), new Keyframe(1f, 0f, -1f, -1f) }; this.radiusCurve = new AnimationCurve(keys); this.radiusMode = true; this.capSmoothing = 0f; this.crinklyness = 0.1f; Keyframe[] keyframeArray2 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.crinkCurve = new AnimationCurve(keyframeArray2); this.seekBlend = 0f; Keyframe[] keyframeArray3 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.seekCurve = new AnimationCurve(keyframeArray3); this.noise = 0.1f; Keyframe[] keyframeArray4 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.noiseCurve = new AnimationCurve(keyframeArray4); this.noiseScaleU = 0.2f; this.noiseScaleV = 0.1f; this.flareSize = 0f; this.flareHeight = 0.1f; this.flareNoise = 0.3f; this.weldHeight = 0.1f; this.weldSpreadTop = 0f; this.weldSpreadBottom = 0f; this.breakingChance = 0f; this.breakingSpot = new Vector2(0.4f, 0.6f); this.frondCount = 1; this.frondWidth = 1f; Keyframe[] keyframeArray5 = new Keyframe[] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }; this.frondCurve = new AnimationCurve(keyframeArray5); this.frondRange = new Vector2(0.1f, 1f); this.frondRotation = 0f; this.frondCrease = 0f; }
IEnumerator StoneMove(AnimationCurve curve, float delay = 0 ) { if (ismoving) yield break; ismoving = true; float timer = 0; Vector3 stoneOriPosition = stone.transform.position; Vector3 shadowOriPosition = shadow.transform.position; while(true) { if (timer > delay) { stone.transform.position = stoneOriPosition + new Vector3(0,curve.Evaluate((timer-delay)/(glowTime + glowDuration)),0); shadow.transform.position = shadowOriPosition - new Vector3(0,curve.Evaluate((timer-delay)/(glowTime + glowDuration)),0); } if (timer > glowTime + glowDuration + delay) break; timer += Time.deltaTime; yield return null; } ismoving = false; yield break; }
/* public static AnimationCurve[] GetPlanAnimationCurve(List<DefaultAction> outputPlan) { int numKeys = outputPlan.Count; AnimationCurve curveX = new AnimationCurve(); AnimationCurve curveY = new AnimationCurve(); AnimationCurve curveZ = new AnimationCurve(); float time = Time.time; Vector3 pos; foreach ( DefaultAction action in outputPlan) { //DefaultAction action = outputPlan.ElementAt(i); if (action != null && action.state != null) { GridTimeState gridTimeState = action.state as GridTimeState; time = gridTimeState.time; pos = gridTimeState.currentPosition; curveX.AddKey(time,pos.x); curveY.AddKey(time,pos.y); curveZ.AddKey(time,pos.z); totalTime = time; } } curves[0] = curveX; curves[1] = curveY; curves[2] = curveZ; return curves; } */ public static float GetPlanAnimationCurve(List<State> outputPlan,AnimationCurve[] curves) { float endTime = 0; float time; Vector3 pos; float speed; if (outputPlan.Count == 0) return endTime; for (int i= 0; i < outputPlan.Count; i++) { time = outputPlan[i]._time ; pos = outputPlan[i].getPosition(); speed = outputPlan[i]._speed; //Debug.LogWarning("adding key " + i + " of " + outputPlan.Count + " " + time + " " +pos); curves[0].AddKey(time,pos.x); curves[1].AddKey(time,pos.y); curves[2].AddKey(time,pos.z); curves[3].AddKey(time,speed); } endTime = outputPlan[outputPlan.Count-1]._time; return endTime; }
public Tween(BezierCurve curve, UnityEvent <float> func, float duration) { this.curve = curve; function = func; this.duration = duration; OnStart = new UnityEvent(); OnFinished = new UnityEvent(); }
public static void Apply(UnityEngine.AnimationCurve src, UnityEngine.AnimationCurve dest) { dest.keys = new Keyframe[] {}; foreach (var keyf in src.keys) { dest.AddKey(keyf); } }
static public int set_keys(IntPtr l) { UnityEngine.AnimationCurve o = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.Keyframe[] v; checkType(l, 2, out v); o.keys = v; return(0); }
static void AnimationCurve_Item_Int32(JSVCall vc) { System.Int32 arg0 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg); UnityEngine.AnimationCurve _this = (UnityEngine.AnimationCurve)vc.csObj; var result = _this[arg0]; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); }
static public int set_postWrapMode(IntPtr l) { UnityEngine.AnimationCurve o = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.WrapMode v; checkEnum(l, 2, out v); o.postWrapMode = v; return(0); }
static public int get_postWrapMode(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); pushEnum(l, (int)self.postWrapMode); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_length(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); pushValue(l, self.length); return(1); } catch (Exception e) { return(error(l, e)); } }
static bool TweenParams_SetEase__AnimationCurve(JSVCall vc, int argc) { int len = argc; if (len == 1) { UnityEngine.AnimationCurve arg0 = (UnityEngine.AnimationCurve)JSMgr.datax.getObject((int)JSApi.GetType.Arg); JSMgr.datax.setObject((int)JSApi.SetType.Rval, ((DG.Tweening.TweenParams)vc.csObj).SetEase(arg0)); } return(true); }
static public int get_keys(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); pushValue(l, true); pushValue(l, self.keys); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_preWrapMode(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); pushEnum(l, (int)self.preWrapMode); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int get_length(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); pushValue(l, self.length); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static bool EaseFactory_StopMotion__Int32__AnimationCurve(JSVCall vc, int argc) { int len = argc; if (len == 2) { System.Int32 arg0 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg); UnityEngine.AnimationCurve arg1 = (UnityEngine.AnimationCurve)JSMgr.datax.getObject((int)JSApi.GetType.Arg); JSMgr.datax.setObject((int)JSApi.SetType.Rval, DG.Tweening.EaseFactory.StopMotion(arg0, arg1)); } return(true); }
static bool AudioSource_SetCustomCurve__AudioSourceCurveType__AnimationCurve(JSVCall vc, int argc) { int len = argc; if (len == 2) { UnityEngine.AudioSourceCurveType arg0 = (UnityEngine.AudioSourceCurveType)JSApi.getEnum((int)JSApi.GetType.Arg); UnityEngine.AnimationCurve arg1 = (UnityEngine.AnimationCurve)JSMgr.datax.getObject((int)JSApi.GetType.Arg); ((UnityEngine.AudioSource)vc.csObj).SetCustomCurve(arg0, arg1); } return(true); }
static public int RemoveKey(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.RemoveKey(a1); return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_keys(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.Keyframe[] v; checkType(l, 2, out v); self.keys = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_postWrapMode(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.WrapMode v; checkEnum(l, 2, out v); self.postWrapMode = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_preWrapMode(IntPtr l) { try { UnityEngine.AnimationCurve self = (UnityEngine.AnimationCurve)checkSelf(l); UnityEngine.WrapMode v; checkEnum(l, 2, out v); self.preWrapMode = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public static ByteBuffer Save(UnityEngine.AnimationClip clip) { EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(clip); FlatBufferBuilder builder = new FlatBufferBuilder(InitBufferSize); Offset <Schema.CurveBinding>[] vecOffsetCurveBindings = new Offset <CurveBinding> [bindings.Length]; for (int i = 0; i < bindings.Length; i++) { UnityEngine.AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, bindings[i]); Keyframe[] kfs = curve.keys; Schema.AnimationCurve.StartKeyFramesVector(builder, kfs.Length); for (int j = kfs.Length - 1; j >= 0; j--) { Schema.KeyFrame.CreateKeyFrame(builder, kfs[j].inTangent, kfs[j].outTangent, kfs[j].tangentMode, kfs[j].time, kfs[j].value); } VectorOffset vecKeyFrames = builder.EndVector(); Schema.AnimationCurve.StartAnimationCurve(builder); Schema.AnimationCurve.AddKeyFrames(builder, vecKeyFrames); Schema.AnimationCurve.AddPostWrapMode(builder, (Schema.WrapMode)curve.postWrapMode); Schema.AnimationCurve.AddPreWrapMode(builder, (Schema.WrapMode)curve.preWrapMode); Offset <Schema.AnimationCurve> offCurve = Schema.AnimationCurve.EndAnimationCurve(builder); StringOffset offPropertyName = builder.CreateString(bindings[i].propertyName); StringOffset offPath = builder.CreateString(bindings[i].path); StringOffset offType = builder.CreateString(bindings[i].type.FullName); Schema.CurveBinding.StartCurveBinding(builder); Schema.CurveBinding.AddPropertyName(builder, offPropertyName); Schema.CurveBinding.AddPath(builder, offPath); Schema.CurveBinding.AddType(builder, offType); Schema.CurveBinding.AddCurve(builder, offCurve); vecOffsetCurveBindings[i] = Schema.CurveBinding.EndCurveBinding(builder); } VectorOffset vecCurveBindings = Schema.AnimationClip.CreateBindingsVector(builder, vecOffsetCurveBindings); Schema.AnimationClip.StartAnimationClip(builder); Schema.AnimationClip.AddFrameRate(builder, clip.frameRate); Schema.AnimationClip.AddWrapMode(builder, (Schema.WrapMode)clip.wrapMode); Schema.AnimationClip.AddBindings(builder, vecCurveBindings); Offset <Schema.AnimationClip> offClip = Schema.AnimationClip.EndAnimationClip(builder); builder.Finish(offClip.Value); return(builder.DataBuffer); }