////////////////////////////////////////////
指定したフォルダからの読み込み
////////////////////////////////////////////
--------------------------------------------
次に、内部データ領域の好きな場所を指定できるか調べた
参考にしたところ---------------------------------
string path = "";
using (AndroidJavaClass jcEnvironment = new AndroidJavaClass ("android.os.Environment"))
using (AndroidJavaObject joExDir = jcEnvironment.CallStatic
("getExternalStorageDirectory")) {
path = joExDir.Call("toString")+"/jp.co.cname.app/";
}
//フォルダがなければ作成
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
//ファイル名入力
path += System.DateTime.Now.Ticks.ToString ()+".png";
---------------------------------
こんな感じにすればいいらしいので
path = joExDir.Call("toString");
のようにして、内部SD領域の先頭にして、
以下のようなスクリプトを書いて実験してみた。
----------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO; // ←Directoryクラスを使うにはコレがいる
public class DispSDAllFilesScr : MonoBehaviour {
private string ErrorMessage = "";
private string allFiles = "";
private string path = "";
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
//解像度に依存せず
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / 800f, Screen.height / 600f, 1f));
if (GUI.Button(new Rect(400, 5, 100, 40), "AllFiles"))
{
dispFiles2();
//dispFiles();
}
GUI.TextArea(new Rect(400, 50, 200, 200), allFiles);
GUI.TextArea(new Rect(400, 300, 200, 100), ErrorMessage);
}
void dispFiles()
{
allFiles = "全ファイル\n";
#if UNITY_EDITOR
string[] path_array = Directory.GetFiles(Application.dataPath, "*.*");
int array_num = path_array.Length;
for (int i = 0; i < array_num; i++)
{
string path = path_array[i];
string fileName = System.IO.Path.GetFileName(path);
allFiles += fileName + "\n";
}
#elif UNITY_ANDROID
//SDのパス 内部getExternalStorageDirectory
string path = "";
using (AndroidJavaClass jcEnvironment = new AndroidJavaClass ("android.os.Environment"))
using (AndroidJavaObject joExDir = jcEnvironment.CallStatic ("getExternalStorageDirectory")) {
path = joExDir.Call("toString"); //内部SDのpath それ以下の指定は/aaa/bbb/みたいにする
}
//フォルダがなければ作成
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
//ファイル名入力
//SDのパス
ErrorMessage = "1";
string[] path_array = Directory.GetFiles(path, "*.*", System.IO.SearchOption.TopDirectoryOnly);
ErrorMessage = "2";
int array_num = path_array.Length;
if(array_num != 0){
for (int i = 0; i < array_num; i++)
{
string path2 = path_array[i]; //path_array[i]は、フルPathになっている
string fileName = System.IO.Path.GetFileName(path2);//ファイル名のみを
allFiles += path2+"\n";
}
}
ErrorMessage = path;
#endif
}
void dispFiles2()
{
allFiles = "フォルダ一覧\n";
#if UNITY_EDITOR
string[] path_array = Directory.GetFiles(Application.dataPath, "*.*");
int array_num = path_array.Length;
for (int i = 0; i < array_num; i++)
{
string path = path_array[i];
string fileName = System.IO.Path.GetFileName(path);
allFiles += fileName + "\n";
}
#elif UNITY_ANDROID
//path = Application.persistentDataPath;
//SDのパス 内部getExternalStorageDirectory
//Directory.GetFilesよりDirectory.EnumerateFilesを使った方がいいかも??
string path = "";
using (AndroidJavaClass jcEnvironment = new AndroidJavaClass ("android.os.Environment"))
using (AndroidJavaObject joExDir = jcEnvironment.CallStatic ("getExternalStorageDirectory")) {
path = joExDir.Call("toString");
}
//フォルダがなければ作成
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
//ファイル名入力
//path += System.DateTime.Now.Ticks.ToString ()+".png";
//SDのパス
ErrorMessage = "1";
string[] path_array = Directory.GetDirectories(path, "*.*", System.IO.SearchOption.TopDirectoryOnly);
ErrorMessage = "2";
int array_num = path_array.Length;
if(array_num != 0){
for (int i = 0; i < array_num; i++)
{
string path2 = path_array[i]; //path_array[i]は、フルPathになっている
//string fileName = System.IO.Path.GetFileName(path2);//ファイル名のみを
allFiles += path2+"\n";
}
}
ErrorMessage = path;
#endif
}
}
----------------------------------------------
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/31(金) 15:05:40|
- Unity
-
| トラックバック:0
-
| コメント:0
腰痛での掃除はきっつい。
重いものが持てない。。。
いつもなら簡単に持てるものが、重く感じる
はやく、良くならないかなぁ~~~
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/31(金) 14:58:34|
- その他
-
| トラックバック:0
-
| コメント:0
新年度で、やることが増えました。
楽しみと辛さがいっぱい
事務所の引っ越しが、一番の楽しみ!!
やはり、新しい場所はいい。
心機一転頑張ろうって気になりますね。
前事務所の掃除が大変・・・
新事務所での整理整頓。
これが一番のつらさ・・・
仕事をしながら・・・整理整頓。
前の事務所より場所が良い分狭いんですよ。
荷物が、全部入らない・・・きっと。
どれを捨てるのか・・・
どれを倉庫にしまうのか・・・
決めなければいけない!
これが一番大変!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/30(木) 23:01:00|
- その他
-
| トラックバック:0
-
| コメント:0
柿ピーが大好きなのですが、
アレルギーがあるために、
どこにでも売っている、亀田の柿ピーが食べられません・・・
あれは美味しかったのに・・・
かといって、おいしくないものは・・・
スーパーで一袋100円とかで売っているものは・・・
食べたくない(気分的に)
というわけで、
三幸の柿の種を食べてます。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/30(木) 22:37:16|
- その他
-
| トラックバック:0
-
| コメント:0
////////////////////////////////////////////
Unityで画像ファイルの書き出し
////////////////////////////////////////////
保存されたのを確認するためには
androidの場合は
/data/data/<アプリのID>/files/
なので、見つけてもいいけど
画面操作で、呼び出せるようにしてみた
ReadImgFile2Obj という名前の planeオブジェクトを作り
画面に並ぶように配置する。
--------- ReadImgFileScr.cs ----------------------
using UnityEngine;
using System.Collections;
using System.IO; //FileStream
#if UNITY_EDITOR
using UnityEditor;
#endif
public class ReadImgFileScr : MonoBehaviour
{
private string imgFile = "myphoto.png";
private string imgSaveFile = "mysave2img.png";
public Texture2D tex;
public Texture2D tex2;
private string path = "";
private string ErrorMessage = "";
void Start()
{
StartCoroutine(LoadImg());
}
byte[] LoadBin(string path)
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] buf = br.ReadBytes((int)br.BaseStream.Length);
br.Close();
return buf;
}
IEnumerator LoadImg()
{
//string path = "";
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
#if UNITY_EDITOR
path = Application.streamingAssetsPath + "\\" + imgFile;
Texture2D tex = new Texture2D(0, 0);
tex.LoadImage(LoadBin(path));
readImgObj.GetComponent
().material.mainTexture = tex;
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = "jar:file://" + Application.dataPath + "!/assets" + "/" + imgFile;
WWW www = new WWW(path);
yield return www;
Texture2D tex = new Texture2D(0, 0);
readImgObj.GetComponent().material.mainTexture = www.texture;
#endif
}
IEnumerator LoadSaveImg()
{
//string path = "";
GameObject writeImgObj = GameObject.Find("ReadImgFile2Obj");
#if UNITY_EDITOR
path = Application.streamingAssetsPath + "\\" + imgSaveFile;
Texture2D tex = new Texture2D(0, 0);
tex.LoadImage(LoadBin(path));
writeImgObj.GetComponent().material.mainTexture = tex;
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
//path = "jar:file://" + Application.dataPath + "!/assets" + "/" + imgSaveFile;
//path = Application.persistentDataPath + "/" + imgSaveFile;
//読み込む場所が違うので、読み込み方式が異なる
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] imageBytes = File.ReadAllBytes(path);
Texture2D tex = new Texture2D(0, 0);
bool isloadbmpSuccess = tex.LoadImage(imageBytes);
writeImgObj.GetComponent().material.mainTexture = tex;
yield return new WaitForSeconds(0f);
#endif
}
IEnumerator SaveImg()
{
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
#if UNITY_EDITOR
//画像の保存
Texture2D tex2 = new Texture2D(0, 0);
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
// 使っているテクスチャをTexture2Dとして使う場合は as Texture2D を使う
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
string filePath = EditorUtility.SaveFilePanel("Save Texture", "", imgSaveFile, "png");
if (filePath.Length > 0)
{
// pngファイル保存.
File.WriteAllBytes(filePath, pngData);
}
//画像の保存
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
//path = "jar:file://" + Application.dataPath + "!/assets" + "/" + imgSaveFile;
path = Application.persistentDataPath + "/" + imgSaveFile;
//path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
ErrorMessage = "FindFile";
ErrorMessage = "FindFile2";
if( pngData != null)
{
ErrorMessage = "FindFile3";
File.WriteAllBytes(path, pngData);
ErrorMessage = "書き込み";
}else{
ErrorMessage = "Error";
}
yield return new WaitForSeconds(0f);
#endif
}
void OnGUI()
{
if (GUI.Button(new Rect(300, 200, 100, 40), "画像保存"))
{
//StartCoroutine("LoadText2");
//StartCoroutine(SaveImg());//OK
//StartCoroutine(SaveImgNew());//ok
StartCoroutine(SaveImgOld());
}
if (GUI.Button(new Rect(300, 250, 100, 40), "画像確認"))
{
//StartCoroutine("LoadText2");
StartCoroutine(LoadSaveImg());
}
GUI.TextArea(new Rect(300, 300, 100, 40), ErrorMessage);
}
IEnumerator SaveImgOld()
{
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
#if UNITY_EDITOR
//画像の保存
Texture2D tex2 = new Texture2D(0, 0);
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
// 使っているテクスチャをTexture2Dとして使う場合は as Texture2D を使う
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
string filePath = EditorUtility.SaveFilePanel("Save Texture", "", imgSaveFile, "png");
if (filePath.Length > 0)
{
// pngファイル保存.
File.WriteAllBytes(filePath, pngData);
}
//画像の保存
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
//.WriteAllBytes方式
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
//path = "jar:file://" + Application.dataPath + "!/assets" + "/" + imgSaveFile;
//path = Application.persistentDataPath + "/" + imgSaveFile;
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
ErrorMessage = "FindFile2";
if( pngData != null)
{
ErrorMessage = "FindFile3";
File.WriteAllBytes(path, pngData);
ErrorMessage = "書き込み";
}else{
ErrorMessage = "Error";
}
yield return new WaitForSeconds(0f);
#endif
}
IEnumerator SaveImgNew()
{
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
#if UNITY_EDITOR
//画像の保存
Texture2D tex2 = new Texture2D(0, 0);
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
// 使っているテクスチャをTexture2Dとして使う場合は as Texture2D を使う
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
string filePath = EditorUtility.SaveFilePanel("Save Texture", "", imgSaveFile, "png");
if (filePath.Length > 0)
{
// pngファイル保存.
File.WriteAllBytes(filePath, pngData);
}
//画像の保存
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
//.Write 方式
Texture2D tex2 = new Texture2D(0, 0);
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
ErrorMessage = "1";
//tex2.ReadPixels (new Rect(0, 0, Screen.width, Screen.height), 0, 0);
using (FileStream BinaryFile = new FileStream(path, FileMode.Create, FileAccess.Write)) {
ErrorMessage = "2";
using (BinaryWriter Writer = new BinaryWriter(BinaryFile)) {
ErrorMessage = "3";
Writer.Write (tex2.EncodeToPNG());
ErrorMessage = "ED";
}
}
yield return new WaitForSeconds(0f);
#endif
}
}
--------- ReadImgFileScr.cs ----------------------
表示させる項目が増えてきたので
すべての void OnGUI(){ の下に
以下の部分を追記する
//解像度に依存せず
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / 800f, Screen.height / 600f, 1f));
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/29(水) 15:46:48|
- Unity
-
| トラックバック:0
-
| コメント:0
この前は、庭のちょっとした場所にピーマンを植えたのですが、
今回は、プランターに、植えてみた。
庭の掃除をしていたら、
完全に枯れているプランターがあったので
洗って、土を入れ替え
ピーマンの種が余っていたので撒いてみた。
直接撒いた種は、いまいちだったので・・・
二回目のチャレンジです。
芽が出てくれればいいなぁ~~~
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/29(水) 15:37:24|
- その他
-
| トラックバック:0
-
| コメント:0
まだ、、、、、芽が出ない!!!!
ジャガイモってこんなに芽が出ないのか~~~~
まぁ、芽自体は少し育った状態で植えているので
ここしばらく、天気が悪かったから
まだなのかぁ~~~
それとも、栄養がないのかなぁ~~~
少しでも土から、葉っぱが出てくれれば
楽しいのに!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/28(火) 21:40:21|
- その他
-
| トラックバック:0
-
| コメント:0
使用感・・・
結論から言うと
直接編集は、使う人には便利だけど
自分で作ったファイルを作り替えるなら・・・
元ファイルを作り替えて
変換したほうが
全然きれいになりそう。。。
というわけで。。。
STANDARDバージョンで十分。だと思う。
私的には、直接編集は面白いと思いますが
きっとあまり使わないだろうな~~~
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/26(日) 11:14:44|
- その他
-
| トラックバック:0
-
| コメント:0
まだ使い込んでいませんが、
仕事の関係で、PDFファイルを作る必要性ができたので
COMPLETEバージョンまでは必要ではなかったけど
そのうち必要になるかも???
というわけで
COMPLETEバージョンを買ってみた。
使用感は、使い込んでから・・・書いていこうと思いますが
直接編集は、いろいろなサイトのレビューにも書いてあったけど
フォントがない場合は結構大変でした。
持っていないフォントだと
自分で編集したところだけフォントが違くなるので
違和感だらけ
なので、全部変更しないと気持ち悪くなる・・・
でも、自分のPCにそのフォントがないのだからしょうがないのだけど
フォントを全部変更するのは面倒・・・
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/25(土) 22:25:28|
- その他
-
| トラックバック:0
-
| コメント:0
4月から新しいところを使うのに、
いまだに引っ越し作業中・・・
間に合うのか。
たぶん間に合う
というか、間に合わないといけない!!
急な仕事も、入って、
作業をなかなかできない・・・
これは、頼むしかない!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/25(土) 18:04:30|
- その他
-
| トラックバック:0
-
| コメント:0
////////////////////////////////////////////
Unityで画像ファイルの書き出し
////////////////////////////////////////////
とりあえず、
書き込み場所は
androidの場合は
path = Application.persistentDataPath + "/" + imgSaveFile;
若しくは
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
として、保存をすればいいらしい。
現在表示されているTextureをTexture2Dとして、読み込んで
tex2 = readImgObj.GetComponent
().material.mainTexture as Texture2D;
pngのバイト情報を取得して
byte[] pngData = tex2.EncodeToPNG();
保存した。
-----------------------------------
//.WriteAllBytes方式
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
if( pngData != null){
File.WriteAllBytes(path, pngData);
ErrorMessage = "書き込み";
}else{
ErrorMessage = "Error";
}
-----------------------------------
また、
-----------------------------------
//.Write 方式
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
Texture2D tex2 = new Texture2D(0, 0);
tex2 = readImgObj.GetComponent().material.mainTexture as Texture2D;
path = string.Format("{0}/{1}", Application.persistentDataPath , imgSaveFile);
byte[] pngData = tex2.EncodeToPNG(); // pngのバイト情報を取得.
ErrorMessage = "1";
using (FileStream BinaryFile = new FileStream(path, FileMode.Create, FileAccess.Write)) {
using (BinaryWriter Writer = new BinaryWriter(BinaryFile)) {
Writer.Write (tex2.EncodeToPNG());
}
}
-----------------------------------
でも、保存された。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/24(金) 20:14:54|
- Unity
-
| トラックバック:0
-
| コメント:0
////////////////////////////////////////////
Unityで外部画像ファイルの読み出し
////////////////////////////////////////////
画像の表示は、
ReadImgFileObjという名前の Planeオブジェクトを作り
-----------------------------------
using UnityEngine;
using System.Collections;
using System.IO; //FileStream
#if UNITY_EDITOR
using UnityEditor;
#endif
public class ReadImgFileScr : MonoBehaviour
{
private string imgFile = "myphoto.png";
private string imgSaveFile = "mysave2img.png";
public Texture2D tex;
private string path = "";
private string ErrorMessage = "";
void Start()
{
StartCoroutine(LoadImg());
}
byte[] LoadBin(string path)
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] buf = br.ReadBytes((int)br.BaseStream.Length);
br.Close();
return buf;
}
IEnumerator LoadImg()
{
GameObject readImgObj = GameObject.Find("ReadImgFileObj");
#if UNITY_EDITOR
path = Application.streamingAssetsPath + "\\" + imgFile;
Texture2D tex = new Texture2D(0, 0);
tex.LoadImage(LoadBin(path));
readImgObj.GetComponent
().material.mainTexture = tex;
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = "jar:file://" + Application.dataPath + "!/assets" + "/" + imgFile;
WWW www = new WWW(path);
yield return www;
Texture2D tex = new Texture2D(0, 0);
readImgObj.GetComponent().material.mainTexture = www.texture;
#endif
}
void OnGUI()
{
GUI.TextArea(new Rect(300, 300, 100, 40), ErrorMessage);
}
}
-----------------------------------
な感じでできたのですが
書き込みが・・・・
結構難したかった。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/22(水) 22:47:49|
- Unity
-
| トラックバック:0
-
| コメント:0
新しい事務所に引っ越すため
椅子を少しきれいにしてみた。
第二弾。
背中の部分は

こんな感じになりました。
全体は、

こんな感じで、
事務椅子に見えなく、
学習机についてそうな椅子になった。
まだ修理する椅子があるので
次は、もう少し写真を撮りたいな。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/21(火) 22:43:45|
- その他
-
| トラックバック:0
-
| コメント:0
カッティングシートで、窓に貼りたかったけど・・・
雨が思ったより強くて貼れそうにない。
午前中畑に行って、
午後シート貼りしようと思っていたけど
雨で、くるってしまった。
もう少し弱くなってくれれば・・・
シート貼りには問題ないのですが
結構雨が多いと、、、
やはりうまくいかないので・・・
失敗したら、またシートを作らないといけないし
今日は、中の掃除をしていようかなぁ~~~
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/21(火) 10:49:13|
- その他
-
| トラックバック:0
-
| コメント:0
新しい事務所に引っ越すため
椅子を少しきれいにしてみた。
まぁ、新しいのを買ってもいいのだけど
布の張替えも面白いので
ダイソーに行って材料を買ってきた
布

クッション

ヌードクッションというものがあったので
これにした。
事務用いすをばらして、
ばらす写真は、撮り忘れた・・・
クッションを置き
その上から布を当て
ひっくり返して
大きいホチキスみたいなタッカーで
布を固定していく

全体をとめる

ひっくり返して


出来上がり
きょうは、座る部分だけ
あした、全体の組み立てまでおこないたいです。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/20(月) 23:05:25|
- その他
-
| トラックバック:0
-
| コメント:0
この前データーだけ、作っておいたものを
プリントアウトしてみた。
昨日作っていたのですが、
6時間くらいかかった。
まぁ、ほかの仕事をしつつ
プリント自体は、機械がおこなってくれるので
問題はなかったけど
やはり、3Dプリンタは、作るのに時間がかかりすぎる。
ちょこっとしたものでも、
すぐに数時間くらいかかり
少し強度をよくしようと思ったら
尋常じゃないくらい時間がかかる
木で工作したほうが絶対に楽のような気がする。
昨日は、親戚の方が来ていたので
まじまじと制作しているところを見学していた。
ちょっと前に、3Dプリンタが流行ったといっても
やはり現物を見たことある人は
すくないのだろう・・・



今回のは、結構失敗です。
めくれちゃってるし・・・
フィラメントがバラバラになってるところがたくさんある。
やはり、空中移動が長いとダメでした・・・
次は、データーを修正して挑戦しよう!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/20(月) 14:05:55|
- 3Dプリンタ
-
| トラックバック:0
-
| コメント:0
----------------- WriteTxtScr.cs-----全文ソース----------------------
using UnityEngine;
using System.Collections;
using System.IO; //System.IO.FileInfo, System.IO.StreamReader, System.IO.StreamWriter//File.ReadAllLines
public class WriteTxtScr : MonoBehaviour
{
private string guitxt = "";
private string guitxt2 = "";
private string outputTextData = "WriteText.txt";
TextReader txtReader;
void Start()
{
guitxt = "ファイルの書き込み";
//StartCoroutine("SaveText");
WriteFile(guitxt);
}
void OnGUI()
{
GUI.TextArea(new Rect(5, 155, 200, 60), guitxt);
if (GUI.Button(new Rect(300, 155, 100, 40), "書き込みテスト"))
{
//StartCoroutine("LoadText2");
ReadLine();
}
GUI.TextArea(new Rect(5, 200, 250, 100), guitxt2);
}
void WriteFile(string txt)
{
string path = "";
//guitxt = "書き込み\n";
if (Application.platform == RuntimePlatform.Android)
{
// Android
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - and\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else if (Application.platform == RuntimePlatform.WindowsEditor)
{
//Unity
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - uni\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else if (Application.platform == RuntimePlatform.WindowsPlayer)
{
// Windows
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - win\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else
{
//other
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - oth\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
}
void WriteFile2(string txt)
{
string path = "";
//guitxt = "書き込み\n";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
#endif
}
IEnumerator SaveText()
{
string path = "";
guitxt = "書き込み\n";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
yield return new WaitForSeconds(0f);
#endif
}
void ReadLine()
{
string txtBuffer = "";
string path = "";
if (Application.platform == RuntimePlatform.Android)
{
// Android
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1ANDROID\r\n";
}
else if (Application.platform == RuntimePlatform.WindowsEditor)
{
// Unity
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1Unity\r\n";
}
else if (Application.platform == RuntimePlatform.WindowsPlayer)
{
// Windows
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1WINDOWS\r\n";
}
else
{
}
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
void ReadLine2()
{
string txtBuffer = "";
string path = "";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "2WINDOWS\r\n";
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "2ANDROID\r\n";
#endif
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
IEnumerator LoadText2()
{
string txtBuffer = "";
string path = "";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "WINDOWS\r\n";
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "ANDROID\r\n";
yield return new WaitForSeconds(0f);
#endif
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
}
---------------- WriteTxtScr.cs------全文ソース----------------------
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/19(日) 17:42:12|
- Unity
-
| トラックバック:0
-
| コメント:0
庭に、ピーマンの種を撒いた。
今日、ダイソーに行ったついでに
ピーマンと枝豆の種を買ってきた。
ダイソーの種は
すごく少ししか入っていないけど
庭にまくのにはちょうどいい・・・
苗を育てないといけないのかもしれないけど
直接撒いてしまった。
芽が出ればいいなぁ~~~~
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/19(日) 17:30:19|
- その他
-
| トラックバック:0
-
| コメント:0
今日は、下のよなものを作った。

パッと見、マンションみたいなのですが
ただの置物ではありません。
とりあえず、作ってみてから
また、
書きます。
それにしても、
blenderで、作るのは面倒・・・
まぁ、blenderでしか作ったことありませんが
それにしても
一個データー作るのに
結構な時間がかかる
さらに、作るのに
また時間がかかる
一個作れば、あとは問題ないのですが
そもそも、3Dプリンタが
いまいちなのは、
やはり、時間がかかりすぎる。。。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/18(土) 17:33:13|
- blender
-
| トラックバック:0
-
| コメント:0
ペットのメダカさんも
ここ一週間くらいで
3匹☆になってしまった。
なぜか、
家族というか家全体で調子が悪い
なんか、ヤバいウイルスでもあるのか???
とりあえず、気を付けないと!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/17(金) 13:37:25|
- その他
-
| トラックバック:0
-
| コメント:0
ここしばらく体調不良だったので
Unity関係のブログを書いている気力がなかった
そのため、
Unity関係の記事が一時的に減ります。
たぶん。
暇ができれば
一気に20個分作るので
というか、
毎日ちょっとずつって出来ない。
一気に進めるしかない・・・
本当に今回の体調不良はヤバかった。
まだ、頭痛がしている・・・
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/17(金) 13:33:21|
- Unity
-
| トラックバック:0
-
| コメント:0
まぁ、この課題は後回しにしておき
制限時間を表示させたい。
MainCameraのPositionを
TransForm.Position を x3 y20 z0
と変更

とりあえず、経過時間を表示させる
playerScr.csに、以下を追加する
-------------------------
public class playerScr : MonoBehaviour {
public Vector3 dir;
public int gameTime;//追加
void Update () {
gameTime = Convert.ToInt32(Time.time);//追加
}
void OnGUI(){//ここから 追加
GUI.Label(new Rect(250, 10, 200, 50),"時間:"+ Convert.ToString(gameTime));
}//ここまで 追加
--------------------------
ゲーム経過時間(Time.time)は、float型なので
int型に変えて(Convert.ToInt32)小数点以下を削除して
文字を表示する為に、Convert.ToStringで、文字列にかえた。
gameTime = Time.time;
だと
小数点以下が表示される
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/17(金) 13:25:30|
- Unity
-
| トラックバック:0
-
| コメント:0
家族も、うつった。
鼻炎だと思ったら、
風邪だった。
足もつらかったから
鼻炎ぽいけど
花粉症からくる鼻炎ではないと思っていた。
それにしても、
一週間くらいたつけど
まだつらいです。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/16(木) 23:36:52|
- その他
-
| トラックバック:0
-
| コメント:0
IEnumerator LoadText2() も
-----------------
void ReadLine()
{
string txtBuffer = "";
string path = "";
if (Application.platform == RuntimePlatform.Android)
{
// Android
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1ANDROID\r\n";
}
else if (Application.platform == RuntimePlatform.WindowsEditor)
{
// Unity
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1Unity\r\n";
}
else if (Application.platform == RuntimePlatform.WindowsPlayer)
{
// Windows
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "1WINDOWS\r\n";
}
else
{
}
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
-----------------
とか
-----------------
void ReadLine2()
{
string txtBuffer = "";
string path = "";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "2WINDOWS\r\n";
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "2ANDROID\r\n";
#endif
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
-----------------
でも、おなじになる
呼び出し方は
WriteFile(guitxt);
ReadLine();
にする。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/16(木) 22:46:21|
- Unity
-
| トラックバック:0
-
| コメント:0
IEnumerator SaveText() の代わりに
-----------------
void WriteFile(string txt)
{
string path = "";
//guitxt = "書き込み\n";
if (Application.platform == RuntimePlatform.Android)
{
// Android
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - and\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else if (Application.platform == RuntimePlatform.WindowsEditor)
{
//Unity
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - uni\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else if (Application.platform == RuntimePlatform.WindowsPlayer)
{
// Windows
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - win\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
else
{
//other
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
guitxt += " - oth\n";
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
}
}
-----------------
とか
-----------------
void WriteFile2(string txt)
{
string path = "";
//guitxt = "書き込み\n";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
#endif
}
-----------------
なんかを使っても、同じになる
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/15(水) 22:18:13|
- Unity
-
| トラックバック:0
-
| コメント:0
ここ数日、体の調子が悪くて、
仕事行って帰ってきて寝るだけだった・・・
ブログ書く体力もなかった。
花粉症の時期は、免疫が弱くなるようで
結構な確率で、重い風邪をひく
あ~~つらい。
今日はだいぶ良かったけど
まだ、足にきている。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/15(水) 22:15:43|
- その他
-
| トラックバック:0
-
| コメント:0
昨日から、花粉症と鼻炎が重くなって
足にきて、寒気もあって
寝込んでしまった
ここずっとあまり寝れなくて
忙しくて、
やはり体に来ました。
今日はゆっくり寝ていよう!!
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/12(日) 16:40:24|
- その他
-
| トラックバック:0
-
| コメント:0
ここで、クイズが表示され、それにこたえると、
ブロックが消えるようにしたい。
地味に書くと以下のようになる
--------------------------------
void OnGUI()
{
if (quesButton == "on")
{
GUI.Label(new Rect(10, 10, 200, 50), "問題:りんごを漢字で書くと");
if (GUI.Button(new Rect(10, 60, 50,20), "林檎"))
{
GameObject.DestroyObject(gameObject);//自分が消える
}
if (GUI.Button(new Rect(10, 110, 50, 20), "林五"))
{
}
if (GUI.Button(new Rect(10, 160, 50, 20), "林吾"))
{
}
}
}
--------------------------------
同じパターンがあるということを示したいので
突っ込みをいれないでください。
こうすると、林檎を押さない限り、ブロックが消えないようになる。



さらに、なんか箇所か、ブロックを置けば、
難易度が上がると思うけど・・・
これだと、問題が数種類だけになる。
さらに正解場所も変えないと、クイズと言えなくなる。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/10(金) 22:32:52|
- Unity
-
| トラックバック:0
-
| コメント:0
ただファイルが保存できているか疑問だったので
書き込まれたファイルを読み込むスクリプトも作った
----------- WriteTxtScr.cs -------------
using UnityEngine;
using System.Collections;
using System.IO; //System.IO.FileInfo, System.IO.StreamReader, System.IO.StreamWriter//File.ReadAllLines
public class WriteTxtScr : MonoBehaviour
{
private string guitxt = "";
private string guitxt2 = "";
private string outputTextData = "WriteText.txt";
TextReader txtReader;
void Start()
{
guitxt = "ファイルの書き込み";
StartCoroutine("SaveText");
}
void OnGUI()
{
GUI.TextArea(new Rect(5, 155, 200, 60), guitxt);
if (GUI.Button(new Rect(300, 155, 100, 40), "書き込みテスト"))
{
StartCoroutine("LoadText2");
}
GUI.TextArea(new Rect(5, 200, 250, 100), guitxt2);
}
IEnumerator SaveText()
{
string path = "";
guitxt = "書き込み\n";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileInfo fi = new FileInfo(path);
using (StreamWriter sw = fi.CreateText())
{
sw.WriteLine(guitxt);
}
yield return new WaitForSeconds(0f);
#endif
}
IEnumerator LoadText2()
{
string txtBuffer = "";
string path = "";
#if UNITY_EDITOR
path = Application.dataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "WINDOWS\r\n";
yield return new WaitForSeconds(0f);
#elif UNITY_ANDROID
path = Application.persistentDataPath + "/" + outputTextData;
FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
txtReader = new StreamReader(file);
guitxt2 = "ANDROID\r\n";
yield return new WaitForSeconds(0f);
#endif
while ((txtBuffer = txtReader.ReadLine()) != null)
{
guitxt2 = guitxt2 + txtBuffer + "\r\n";
}
}
}
----------- WriteTxtScr.cs -------------
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/08(水) 22:51:30|
- Unity
-
| トラックバック:0
-
| コメント:0
さっき、プリントアウトしていた
スマホスタンド
買い物に行っている間に終わってました。
修正したら、
前よりもスマホのおいているときの安定感が増しました。
さらに安定するように
滑り止めマットを付けてみました。


さらに、以前作ったボードスタンドも
使用しているところを出してなかったから
写真を撮りました。
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 関連記事
-
- 2017/03/08(水) 13:03:36|
- blender
-
| トラックバック:0
-
| コメント:0
次のページ