Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/055cdc4f33ba12672188 to your computer and use it in GitHub Desktop.
Save tsubaki/055cdc4f33ba12672188 to your computer and use it in GitHub Desktop.
iOS向け、ローディング時にアニメーションを行う
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class LoadingAnimation : SingletonMonobehaviour<LoadingAnimation>{
[DllImport("__Internal")]
static extern void _Init();
[DllImport("__Internal")]
static extern void _LoadStart();
[DllImport("__Internal")]
static extern void _LoadEnd();
public void Start()
{
_Init ();
DontDestroyOnLoad(gameObject);
}
public void LoadStart(){
_LoadStart();
}
public void OnLevelWasLoaded()
{
_LoadEnd();
}
}
#import "UnityAppController.h"
PeripheralManager* p2pmanager;
UIImageView *imageView;
NSMutableArray *imageList;
extern "C" {
void Init();
void LoadStart();
void LoadEnd();
}
void Init()
{
imageList = [NSMutableArray array];
for (NSInteger i = 1; i < 6; i++) {
NSString *imagePath = [NSString stringWithFormat:@"sai1_%d.png", i];
UIImage *img = [UIImage imageNamed:imagePath];
[imageList addObject:img];
}
CGRect rect = CGRectMake(320, 240, 128, 128);
imageView = [[UIImageView alloc]initWithFrame:rect];
imageView.image = imageView.image = [imageList objectAtIndex:0];
imageView.animationImages = imageList;
imageView.animationDuration = 0.5;
imageView.animationRepeatCount = 0;
}
void LoadStart() {
Init();
UnityAppController* appController = GetAppController();
[appController.unityView addSubview:imageView];
[imageView startAnimating];
}
void LoadEnd()
{
[imageView removeFromSuperview];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment