Beispiel #1
0
        //ロード
        protected IEnumerator AsyncSceneLoadStart(string scene, float wait = 0.5f)
        {
            //読み込みチェック
            if (UnityEngine.SceneManagement.SceneManager.GetSceneByName(scene) == null)
            {
                InstantLog.StringLogError("Scene Missing");
                yield break;
            }

            //読み込み開始
            _async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(scene);
            _async.allowSceneActivation = false;

            InstantLog.StringLog("Load Start", StringExtensions.TextColor.darkblue);

            //読み込み中
            while (_async.progress < 0.9f)
            {
                yield return(new WaitForEndOfFrame());
            }

            //読み込み終了
            InstantLog.StringLog("Scene Loaded", StringExtensions.TextColor.blue);
            if (_callbacks != null)
            {
                _callbacks();
            }
            yield return(new WaitForSeconds(wait));

            _async.allowSceneActivation = true;
        }
Beispiel #2
0
        public static T AddComponentSafe <T>(this UdonBehaviour obj) where T : Component
        {
            if (null == obj || obj.IsDestroyed)
            {
                InstantLog.StringLogWarning("unsafe AddComponent call");
                return(null);
            }

            return(obj.gameObject.AddComponent <T>());
        }
Beispiel #3
0
        public static T GetComponentInParentSafe <T>(this GameObject obj) where T : Component
        {
            if (null == obj.GetComponentInParent <T>())
            {
                InstantLog.StringLogWarning("unsafe GetComponent call");
                return(null);
            }

            return(obj.GetComponentInParent <T>());
        }
Beispiel #4
0
        public static void InvokeSafe <T>(this Action <T> action, T arg)
        {
            if (null == action)
            {
                InstantLog.StringLogWarning("Action Missing");
                return;
            }

            action(arg);
        }
Beispiel #5
0
        //Component単位のactive
        public virtual void SetEnable <T>(bool able) where T : Component
        {
            T component = GetComponent <T>();

            if (component == null)
            {
                InstantLog.StringLogError("This object doesn't have any designed components.");
                return;
            }

            (GetComponent <T>() as MonoBehaviour).enabled = able;
        }
Beispiel #6
0
        public static T GetComponentInChildrenAddSafe <T>(this GameObject obj) where T : Component
        {
            if (null == obj.GetComponentInChildren <T>())
            {
                InstantLog.StringLogWarning("unsafe GetComponent call");
                GameObject _obj = new GameObject();
                _obj.transform.SetParent(obj.transform);
                _obj.AddComponent <T>();
                return(null);
            }

            return(obj.GetComponentInChildren <T>());
        }
Beispiel #7
0
        public string GetValue(string key)
        {
            string value;

            if (_localizedTextMap.TryGetValue(key, out value))
            {
                return(value);
            }
            else
            {
                InstantLog.StringLogWarning("Invalid Localization Key");
                return(key);
            }
        }
 public static void CreateInstance()
 {
     if (null != _instance)
     {
         InstantLog.StringLogWarning("Instance has already maked");
         return;
     }
     else
     {
         GameObject instanceObject = new GameObject(ComponentName);
         T          instance       = instanceObject.AddComponent <T>();
         _instance = instance;
         _instance.Initialize();
     }
 }
Beispiel #9
0
        public static async Task <T> PostRequestAsync <T>(string endpoint, byte[] post)
        {
            int number;

#if UNITY_EDITOR
            InstantLog.StringLog($"POST@REQUEST#{_requestNumber}: {endpoint}", StringExtensions.TextColor.yellow);
            number = _requestNumber++;
#endif
            var www = await ObservableWWW.Post(endpoint, post);

            if (www == null)
            {
                Debug.LogError("www request error");
            }
#if UNITY_EDITOR
            InstantLog.StringLog($"POST@RESPONCE#{number}: {www}", StringExtensions.TextColor.yellow);
#endif
            return(JsonUtility.FromJson <T>(www));
        }
Beispiel #10
0
        public static async Task <string> PostRequestAsync(string endpoint, WWWForm form)
        {
            int number;

#if UNITY_EDITOR
            InstantLog.StringLog($"POST@REQUEST#{_requestNumber}: {endpoint}", StringExtensions.TextColor.yellow);
            number = _requestNumber++;
#endif
            var www = await ObservableWWW.Post(endpoint, form);

            if (www == null)
            {
                Debug.LogError("www request error");
            }
#if UNITY_EDITOR
            InstantLog.StringLog($"POST@RESPONCE#{number}: {www}", StringExtensions.TextColor.yellow);
#endif
            return(www);
        }
Beispiel #11
0
        /// <summary>
        /// ファイルのバイナリ読み出し
        /// </summary>
        /// <param name="path">バイナリのパス</param>
        /// <returns>バイト配列</returns>
        public static byte[] ReadBinary(string path, bool deleteFlg = false)
        {
            if (!File.Exists(path))
            {
                InstantLog.StringLogError("ReadBinary : file does not exist");
                return(null);
            }

            var fs = new FileStream(path, FileMode.Open, FileAccess.Read);

            byte[] bs = new byte[fs.Length];
            fs.Read(bs, 0, bs.Length);
            if (deleteFlg)
            {
                File.Delete(path);
            }
            fs.Close();

            return(bs);
        }
Beispiel #12
0
        public void Play()
        {
            if (TextAnimation == null)
            {
                InstantLog.StringLogError("Animation isn't set");
                return;
            }

            TextAnimation
            .OnStart(() =>
            {
                OnAnimationStarted?.Invoke();
            })
            .OnComplete(() =>
            {
                OnAnimationEnded?.Invoke();
            });

            TextAnimation.Play();
        }
Beispiel #13
0
        private void LoadLocalizationFile()
        {
            string filePath = Path.Combine(Application.streamingAssetsPath, LOCALIZATION_FILE_PATH);

            if (File.Exists(filePath))
            {
                string[] lines = File.ReadAllLines(filePath);
                for (int i = 0; i < lines.Length; ++i)
                {
                    var split = lines[i].Split(KEY_VALUE_SPLIT);
                    if (split == null || split.Length != 2)
                    {
                        continue;
                    }
                    _localizedTextMap.Add(split[0], split[1]);
                }
            }
            else
            {
                InstantLog.StringLogError("Missing Localization File");
            }
        }