Skip to content

Instantly share code, notes, and snippets.

@tamanugi
Last active August 21, 2016 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamanugi/bed35ef3865ba0c28c78bccfcf627de0 to your computer and use it in GitHub Desktop.
Save tamanugi/bed35ef3865ba0c28c78bccfcf627de0 to your computer and use it in GitHub Desktop.
VR空間でやる夫作品を読んでみる (β) ref: http://qiita.com/tamanugi/items/4283cd5c188c8fb427ff
       ____
     /      \
   /  _ノ  ヽ、_  \
  / o゚((●)) ((●))゚o \  ほんとは現実世界でもっとやる夫を読みたいんだお…
  |     (__人__)    |
  \     ` ⌒´     /
     ____
     /      \
   /  _ノ  ヽ、_  \
  /  o゚⌒   ⌒゚o  \  でも現実世界は仕事で忙しくてそんな暇ないんだお・・・
  |     (__人__)    |  
  \     ` ⌒´     /
       ____
     /⌒  ⌒\
   /( ●)  (●)\
  /::::::⌒(__人__)⌒::::: \   だからVRでやる夫をよむお!!
  |     |r┬-|     |
  \      `ー'´     /
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class AAAnimationStartScript : MonoBehaviour, IPointerEnterHandler {
private AAObjectManager _script;
private bool _singleFlg = true;
public void Start(){
var go = GameObject.Find("AAObjectManager");
_script = go.GetComponent<AAObjectManager>();
}
public void OnPointerEnter(PointerEventData eventData)
{
if (_singleFlg) {
_script.AAStart ();
_singleFlg = false;
}
}
}
$ git clone https://github.com/googlevr/gvr-unity-sdk.git
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class AAObjectManager : MonoBehaviour {
private GameObject _viewAAObject = null;
private List<TextAsset> _textAssetList;
private int _currentPage = 0;
private bool isFinish = true;
// Use this for initialization
void Start () {
Debug.Log (Resources.LoadAll("AA",typeof(TextAsset)).Length);
// Loading AA
_textAssetList = Resources.LoadAll("AA",typeof(TextAsset)).Cast<TextAsset>().ToList();
Debug.Log (_textAssetList);
// Binding GameObject to variable
_viewAA = transform.FindChild ("ViewAA").gameObject;
}
private int _count = 0;
// Update is called once per frame
void Update () {
_count++;
if(_count == 300 && !isFinish) {
FadeOut ();
_count = 0;
}
}
// FadeOut
void FadeOut(){
Vector3 dist_pos = _viewAAObject.transform.position + (new Vector3(0,1000,0));
Debug.Log (dist_pos);
var moveHash = new Hashtable();
moveHash.Add ("position", dist_pos);
moveHash.Add ("time", 1f);
moveHash.Add ("easeType", "easeInOutBack");
moveHash.Add ("oncomplete", "FadeIn");
moveHash.Add ("oncompletetarget", this.gameObject);
iTween.MoveTo (_viewAAObject, moveHash);
_currentPage++;
if (_currentPage > _textAssetList.Count) {
isFinish = true;
}
}
// FadeIn
public void FadeIn(){
Debug.Log ("FadeIn");
_viewAAObject.transform.position = new Vector3 (-470, -660, 480);
_viewAAObject.GetComponent<TextMesh> ().text = isFinish?"Fin.":_textAssetList[_currentPage].text;
var dist = _viewAAObject.transform.position + (new Vector3 (0, 1000, 0));
var moveHash = new Hashtable();
moveHash.Add ("position", dist);
moveHash.Add ("time", 1f);
moveHash.Add ("easeType", "easeInOutBack");
iTween.MoveTo (_viewAAObject, moveHash);
}
public void AAStart(){
isFinish = false;
_count = 0;
_currentPage = 0;
FadeIn ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment