public IEnumerator createFrame(TIME.Animation anim, int index) { string url = "http://" + databaseAddress + "/playtime/createFrame.php"; WWWForm form = new WWWForm(); byte[] frameData = anim.frames[index].getBytes(); form.AddField("animID", anim.id); form.AddField("frameIndex", index); form.AddField("duration", anim.frames[index].durationMillis()); form.AddField("frameDataLength", frameData.Length); form.AddBinaryData("frameData", frameData); WWW www = new WWW(url, form); while (!www.isDone && www.error == null) { ; } if (createdFrame != null) { if (!int.TryParse(www.text, out createdFrame.id)) { print(www.text); } } yield return(null); }
public void populateFrames(TIME.Animation anim) { currentAnim = anim; foreach (Transform child in frameGroup.transform) { Destroy(child.gameObject); } for (int i = 0; i < anim.frames.Count; i++) { GameObject preview = Instantiate <GameObject>(framePrefab); preview.transform.SetParent(frameGroup.transform, false); RectTransform rt = preview.GetComponent <RectTransform>(); rt.anchoredPosition = new Vector2((120 * (i % 6) + 50), -20 - (160 * (i / 6))); GameObject frameImage = preview.transform.FindChild("FrameImage").gameObject; GameObject durationGO = preview.transform.Find("Duration").gameObject; frameImage.GetComponent <RawImage>().texture = currentAnim.frames[i].texture; durationGO.GetComponent <InputField>().text = currentAnim.frames[i].duration.ToString(); FrameControl fc = durationGO.GetComponent <FrameControl>(); fc.frameID = i; fc.animEditScreen = this; } RectTransform rectTransform = newFrameBtn.GetComponent <RectTransform>(); rectTransform.anchoredPosition = new Vector2((120 * (currentAnim.frames.Count % 6) + 50), -20 - (160 * (anim.frames.Count / 6))); animPreview.anim = currentAnim; }
public void createNewAnimation() { TIME.Animation anim = new TIME.Animation(); DatabaseManager.getInstance().createdAnimation = anim; StartCoroutine(DatabaseManager.getInstance().createAnimation(currentFigurine.key)); TIME.Frame frame = new TIME.Frame(); frame.duration = 1f; DatabaseManager.getInstance().createdFrame = frame; anim.frames.Add(frame); currentFigurine.animations.Add(anim); goToFrameEditScreenBulk(anim, 0); }
public IEnumerator deleteAnimation(TIME.Animation anim) { string url = "http://" + databaseAddress + "/playtime/deleteAnimation.php"; WWWForm form = new WWWForm(); form.AddField("animID", anim.id); WWW www = new WWW(url, form); yield return(www); }
public IEnumerator getFrames(TIME.Animation anim) { string url = "http://" + databaseAddress + "/playtime/getFrames.php"; WWWForm form = new WWWForm(); form.AddField("animID", anim.id); WWW www = new WWW(url, form); yield return(www); string[] delimiters = { "<br>" }; string[] results = www.text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (results.Length == 0) { // Animation has no frames in the database. } else { TIME.Frame[] frames = new TIME.Frame[results.Length]; // for each frame of this animation for (int i = 0; i < results.Length; i++) { print(results[i]); int frameID; string[] delim = { "," }; string[] vals = results[i].Split(delim, StringSplitOptions.None); if (int.TryParse(vals[0], out frameID)) { TIME.Frame frame = new TIME.Frame(); frame.id = frameID; int index = int.Parse(vals[1]); frame.duration = int.Parse(vals[2]) / 1000f; yield return(StartCoroutine(getFrameData(frame))); frames[index] = frame; } } // Now add the frames to the animation in the correct order // just in case they were not retrieve in the correct order on the DB for (int i = 0; i < frames.Length; i++) { anim.frames.Add(frames[i]); } } }
public void goToAnimationEditScreen(TIME.Animation anim) { placeRfidScreenTop.SetActive(false); animationListScreenTop.SetActive(false); frameAnimationPreviewScreenTop.SetActive(false); createNewAnimationScreenTop.SetActive(false); animationListScreenBottom.SetActive(false); frameEditScreenBottom.SetActive(false); createNewAnimationScreenBottom.SetActive(false); animationPreviewScreenTop.SetActive(true); animationEditScreenBottom.SetActive(true); AnimationEditScreen aes = animationEditScreenBottom.GetComponent <AnimationEditScreen>(); aes.populateFrames(anim); }
public void goToFrameEditScreenBulk(TIME.Animation anim, int frameID) { placeRfidScreenTop.SetActive(false); animationListScreenTop.SetActive(false); animationPreviewScreenTop.SetActive(false); frameAnimationPreviewScreenTop.SetActive(false); animationListScreenBottom.SetActive(false); animationEditScreenBottom.SetActive(false); frameEditScreenBottom.SetActive(false); createNewAnimationScreenTop.SetActive(true); createNewAnimationScreenBottom.SetActive(true); FrameEditScreen fes = createNewAnimationScreenBottom.GetComponent <FrameEditScreen>(); fes.batchEditMode = true; fes.initialize(anim, frameID); }
public IEnumerator updateFrame(TIME.Animation anim, int index) { string url = "http://" + databaseAddress + "/playtime/updateFrame.php"; WWWForm form = new WWWForm(); byte[] frameData = anim.frames[index].getBytes(); form.AddField("id", anim.frames[index].id); form.AddField("frameIndex", index); form.AddField("duration", anim.frames[index].durationMillis()); form.AddField("frameDataLength", frameData.Length); form.AddBinaryData("data", frameData); WWW www = new WWW(url, form); yield return(www); }
public IEnumerator getAnimations(TIME.Figurine figurine) { string url = "http://" + databaseAddress + "/playtime/getAnimations.php"; WWWForm form = new WWWForm(); form.AddField("rfidKey", figurine.key); WWW www = new WWW(url, form); yield return(www); string[] delimiters = { "<br>" }; string[] results = www.text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (results.Length == 0) { // Figurine does not exist or has no animations in the database. } else { // for each animation associated to this figurine for (int i = 0; i < results.Length; i++) { print(results[i]); int animID; if (int.TryParse(results[i], out animID)) { TIME.Animation anim = new TIME.Animation(); anim.id = animID; yield return(StartCoroutine(getFrames(anim))); figurine.animations.Add(anim); } } } doneFetchingAnimations = true; }
public void initialize(TIME.Animation anim, int frameID) { currentAnim = anim; currentFrameIndex = frameID; if (anim.frames.Count > 1) { previousFrameOnionSkin.enabled = true; int prevFrameID = (currentFrameIndex - 1); if (prevFrameID < 0) { prevFrameID += currentAnim.frames.Count; } previousFrameOnionSkin.texture = currentAnim.frames[prevFrameID].texture; } else { previousFrameOnionSkin.enabled = false; } framePreview.texture = currentAnim.frames[currentFrameIndex].texture; animPreview.anim = currentAnim; }