やまめも

【 ゲーム開発・日々のことについて 】

【C#】デリゲート(delegate) 使用例 第一弾

delegate例
例1

public void FacebookShare (int id) {
	
	string msg = BossSource._item[id]._shareHeadline;
	Sprite ShareSprite  = BossSource._item[id]._bossShareSprite;
	*****.Facebook.PostImageWithDialog(msg ,ShareSprite.texture, OnFacebookShareComplete);
}

void OnFacebookShareComplete (*****.Social.IActionResult result)
{
	if(result.IsSuccess){
		ShowModal("Thanks For Posting");
		EventManager.ShareSccessMethod();
	}else{
		ShowModal(result.Error);
	}
	EventManager.onFinishUIShareMethod();
}


例2

public void FacebookShare (int id) {
	
	string msg = BossSource._item[id]._shareHeadline;
	Sprite ShareSprite  = BossSource._item[id]._bossShareSprite;
	*****.Facebook.PostImageWithDialog(msg ,ShareSprite.texture, delegate(*****.Social.IActionResult result) {
		if(result.IsSuccess){
			ShowModal("Thanks For Posting");
			EventManager.ShareSccessMethod();
		}else{
			ShowModal(result.Error);
		}
		EventManager.onFinishUIShareMethod();
	});
}