Last active
August 29, 2015 14:05
-
-
Save tsubaki/055cdc4f33ba12672188 to your computer and use it in GitHub Desktop.
iOS向け、ローディング時にアニメーションを行う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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