どうもstaticについてよく理解できておらず、エラーが多発してしまい混乱してしまっているので、解決の糸口を見つけられるよう皆様のお力をお借りしたいと思います。
Unity関係のフォーラムを探して投稿するよりかは、もっと根本的なC#の問題だと私なりに考えたため、こちらに質問させていただきました。
私の理解度ですが、Cをコンソールアプリケーションで簡易な変数操作等の演習問題を行った程度、C#はUnityで初めて触れた程度です。
(Unity2017 - 2Dproject , VS2015 , 操作キャラにアタッチしたスクリプトの内の一つ)
(泥ビルドした際にフリック操作で移動・ダブルタップで攻撃を行おうと、タブレット用の入力補助スクリプトを組もうとしています)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SmaphoOperation : MonoBehaviour {
private static Vector2 p_start, p_now;
private static float rad;
private static float noInputMargin;
public static bool isTouchSupported;
void Start () {
isTouchSupported = Input.touchSupported;
noInputMargin = 10f;
p_start = new Vector2();
p_now = new Vector2();
}
void Update(){
//全処理スキップ条件
if ((isTouchSupported == false)||(Input.touchCount == 0)) return;
//現在タップ位置を更新
p_now = Vector2.Set(Input.touches[0].position.x, Input.touches[0].position.y);
//一本目指のタップ開始位置を記憶
if (Input.touches[0].phase == TouchPhase.Began) {
p_start = Vector2.Set(Input.touches[0].position.x, Input.touches[0].position.y);
}
}
//-----//-----//-----//-----//-----//-----//-----//-----
//フリックしても動作しない遊びを設定
public static void SetTouchNoinputMargin(float a) {
noInputMargin = Mathf.Abs(a);
}
//Inputの攻撃ボタンのダブルタップVER.
//面倒だから押してるかそうでないかだけ取得する
public static bool GetTouchFire() {
return (1 < Input.touchCount);
}
public static float GetTouchAxisHorizontal(){
//書き途中
}
}
staticがどうのvoidがどうのと警告を出され朧気な知識で検索をかけて、非staticなメンバーは参照していないと思うんだけどなぁとなんとなくで手当たり次第にいじくり回して現在に至ります。
終いには、操作キャラクターにアタッチしている他のスクリプトではハイライトされている「Mathf.~」「Input.~」も、このスクリプトではハイライトされていないという訳の分からない自体に混乱がマスばかりです。
とにかく、目下の問題、staticで出ているエラーを収拾したいです。
ご教示お願いします……。