현재 테스트 광고 단위를 사용하는데

 

배너의 크기를 조절하던 중 오류가 났다.

 

분명 커스터마이징이 가능한 줄 알았는데 애드몹에서 지정된 사이즈로만

 

변경 할 수 있던 것이다.

 

본 프로젝트에는 크기에 맞춤을 적용하였다.

 

https://developers.google.com/admob/unity/banner?hl=ko

 

배너 광고  |  Unity  |  Google for Developers

이 페이지는 Cloud Translation API를 통해 번역되었습니다. 배너 광고 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 배너 보기는 화면 안의 한 지점을 차지하는

developers.google.com

using UnityEngine;
using GoogleMobileAds.Api;
using System;
using System.Drawing;

public class BannerManager : MonoBehaviour
{
    public static BannerManager instance;
    public static BannerManager Instance
    {
        get
        {
            // Singleton 패턴을 이용하여 단일 인스턴스 반환
            if (instance == null)
            {
                instance = FindObjectOfType<BannerManager>();
                if (instance == null)
                {
                    GameObject adMobManagerGO = new GameObject();
                    instance = adMobManagerGO.AddComponent<BannerManager>();
                    adMobManagerGO.name = "AdMobManager";
                    DontDestroyOnLoad(adMobManagerGO);
                }
            }
            return instance;
        }
    }

    public string _adUnitId;

    // 광고 뷰 객체
    BannerView _bannerView;

    public void Awake()
    {
        // 싱글톤 인스턴스 설정
        if (instance == null)
        {
            instance = this as BannerManager;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }

    public void Start()
    {
        //// Google Mobile Ads SDK 초기화
        MobileAds.Initialize((InitializationStatus initStatus) =>
        {
            // SDK 초기화 콜백
            Debug.Log("Google Mobile Ads SDK initialized.");
            // 광고 뷰 생성
            //_bannerView = new BannerView(_adUnitId, AdSize.Banner, AdPosition.Bottom);


            //AdSize adSize = new AdSize(350, 50);

            //_bannerView = new BannerView(_adUnitId, adSize, AdPosition.Bottom);

            CreateBannerView();

            ListenToAdEvents();
        });


        //CreateBannerView();

#if UNITY_ANDROID
        _adUnitId = "ca-app-pub-3940256099942544/6300978111"; // 안드로이드 테스트 광고 단위 ID
#elif UNITY_IPHONE
        _adUnitId = "ca-app-pub-3940256099942544/2934735716"; // iOS 테스트 광고 단위 ID
#else
        _adUnitId = "unused"; // 기타 플랫폼 또는 테스트에 사용되지 않는 경우
#endif
    }

    public void CreateBannerView()
    {
        Debug.Log("Creating banner view");

        // 기존 배너 뷰가 있으면 제거
        //if (_bannerView != null)
        //{
        //    _bannerView.Destroy();
        //}

        // Use the AdSize argument to set a custom size for the ad.
        AdSize adSize = AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);


        //_bannerView = new BannerView(_adUnitId, adSize, AdPosition.Bottom);
        _bannerView = new BannerView(_adUnitId, adSize, AdPosition.Bottom);
       
        ListenToAdEvents();
    }/// <summary>
     /// Creates the banner view and loads a banner ad.
     /// </summary>
    public void LoadAd()
    {
        // create an instance of a banner view first.
        if (_bannerView == null)
        {
            CreateBannerView();
        }

        // create our request used to load the ad.
        var adRequest = new AdRequest();

        // send the request to load the ad.
        Debug.Log("Loading banner ad.");
        _bannerView.LoadAd(adRequest);
    }
    /// <summary>
    /// listen to events the banner view may raise.
    /// </summary>
    public void ListenToAdEvents()
    {
        // Raised when an ad is loaded into the banner view.
        _bannerView.OnBannerAdLoaded += () =>
        {
            Debug.Log("Banner view loaded an ad with response : "
                + _bannerView.GetResponseInfo());
        };
        // Raised when an ad fails to load into the banner view.
        _bannerView.OnBannerAdLoadFailed += (LoadAdError error) =>
        {
            Debug.LogError("Banner view failed to load an ad with error : "
                + error);
        };
        // Raised when the ad is estimated to have earned money.
        _bannerView.OnAdPaid += (AdValue adValue) =>
        {
            Debug.Log(String.Format("Banner view paid {0} {1}.",
                adValue.Value,
                adValue.CurrencyCode));
        };
        // Raised when an impression is recorded for an ad.
        _bannerView.OnAdImpressionRecorded += () =>
        {
            Debug.Log("Banner view recorded an impression.");
        };
        // Raised when a click is recorded for an ad.
        _bannerView.OnAdClicked += () =>
        {
            Debug.Log("Banner view was clicked.");
        };
        // Raised when an ad opened full screen content.
        _bannerView.OnAdFullScreenContentOpened += () =>
        {
            Debug.Log("Banner view full screen content opened.");
        };
        // Raised when the ad closed full screen content.
        _bannerView.OnAdFullScreenContentClosed += () =>
        {
            Debug.Log("Banner view full screen content closed.");
        };
    }/// <summary>
     /// Destroys the banner view.
     /// </summary>
    public void DestroyAd()
    {
        if (_bannerView != null)
        {
            Debug.Log("Destroying banner view.");
            _bannerView.Destroy();
            _bannerView = null;
        }
    }
}

 

using UnityEngine;
using Firebase.Analytics;

public class AdManager : MonoBehaviour
{
    private static AdManager instance;

    public static AdManager Instance
    {
        get
        {
            if (instance == null)
            {
                instance = FindObjectOfType<AdManager>();
                if (instance == null)
                {
                    GameObject adManagerGO = new GameObject();
                    instance = adManagerGO.AddComponent<AdManager>();
                    adManagerGO.name = "AdManager";
                    DontDestroyOnLoad(adManagerGO);
                }
            }
            return instance;
        }
    }

    private void Awake()
    {
        if (instance == null)
        {
            instance = this as AdManager;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }

    public void Start()
    {
        // Initialize Firebase Analytics
        FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
        FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventAppOpen);
        BannerManager.Instance.LoadAd();
    }

    public void ShowInterstitialAd()
    {
        // Show interstitial ad logic here
        // For example, assuming _interstitialAd is an instance of your interstitial ad
        // and it's shown successfully, log the event
        LogInterstitialAdShownEvent();
    }

    private void LogInterstitialAdShownEvent()
    {
        // Log an event indicating the interstitial ad was shown
        FirebaseAnalytics.LogEvent("interstitial_ad_shown");
    }
}

 

 

 

public void AddLeaderboard(int score)
{
    PlayGamesPlatform.Instance.ReportScore(score, GPGSIds.leaderboard_highscore, (bool success) =>
    {
        if (success)
        {
            Debug.Log("리더보드에 점수가 성공적으로 추가되었습니다.");

        }
        else
        {
            Debug.Log("리더보드 점수 추가에 실패했습니다.");
        }
    });
}
IEnumerator CoStart()
{
    Debug.Log("몬스터가 클릭됨");
    anim.SetTrigger("Hit");
    hp--;
    currentScore++;
    Debug.Log(currentScore);
    UpdateScoreText();

    if (hp <= 0)
    {
        anim.SetBool("Die", true);
        monster.interactable = false;
        restartBtn.gameObject.SetActive(true);


        // 게임 종료 시 클릭 횟수 PlayerPrefs에 저장
        PlayerPrefs.SetInt(PlayerPrefsKey, currentScore);
        PlayerPrefs.Save();



        GPGSManager.Instance.AddLeaderboard(currentScore);
        GPGSManager.Instance.ShowLeaderBoard();
    }
    yield return null;
}

 

게임에 사용할 스토리 제작

캐릭터의 이름이 주인공인지 적인지 구별하여

그에따라 대화의 id를 찾아서 대화를 띄어주는 것 연구중..

 

using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class UISound : MonoBehaviour
{
    public AudioSource backgroundAudioSource;
    public AudioSource effectAudioSource;

    public Slider backgroundSoundSlider;
    [SerializeField] private TMP_Text backgroundSoundAmount;

    public Slider effectSoundSlider;
    [SerializeField] private TMP_Text effectSoundAmount;

    private int backgroundSoundValue;
    private int effectSoundValue;

    private IEnumerator CoPlay;
    private IEnumerator CoEffect;

    void Start()
    {
        // 슬라이더 값 로드
        LoadSoundSettings();

        backgroundSoundSlider.onValueChanged.AddListener(delegate { UpdateBackgroundSoundAmount(); });
        effectSoundSlider.onValueChanged.AddListener(delegate { UpdateEffectSoundAmount(); });

        UpdateBackgroundSoundAmount();
        UpdateEffectSoundAmount();

        CoPlay = CoPlayBackgroundMusic();
        StartCoroutine(CoPlay);
        CoEffect = CoPlayEffectMusic();
        StartCoroutine(CoEffect);
    }

    public IEnumerator CoPlayBackgroundMusic()
    {
        backgroundAudioSource.loop = true;
        backgroundAudioSource.Play();

        while (true)
        {
            float backVolume = backgroundSoundValue / 100f;
            backgroundAudioSource.volume = backVolume;
            yield return null;
        }
    }

    public IEnumerator CoPlayEffectMusic()
    {
        effectAudioSource.loop = true;
        effectAudioSource.Play();
        while (true)
        {
            float volume = effectSoundValue / 100f;
            effectAudioSource.volume = volume;
            yield return null;
        }
    }

    void UpdateBackgroundSoundAmount()
    {
        backgroundSoundValue = (int)backgroundSoundSlider.value;
        backgroundSoundAmount.text = backgroundSoundValue.ToString();
        SaveSoundSettings(); // 슬라이더 값 변경 시 저장

        Debug.Log($"Background Sound Value: {backgroundSoundValue}");
    }

    void UpdateEffectSoundAmount()
    {
        effectSoundValue = (int)effectSoundSlider.value;
        effectSoundAmount.text = effectSoundValue.ToString();
        SaveSoundSettings(); // 슬라이더 값 변경 시 저장

        Debug.Log($"Effect Sound Value: {effectSoundValue}");
    }

    void SaveSoundSettings()
    {
        PlayerPrefs.SetInt("BackgroundSoundValue", backgroundSoundValue);
        PlayerPrefs.SetInt("EffectSoundValue", effectSoundValue);
        PlayerPrefs.SetString("BackgroundSoundAmount", backgroundSoundAmount.text);
        PlayerPrefs.SetString("EffectSoundAmount", effectSoundAmount.text);
        PlayerPrefs.Save();

        Debug.Log("Sound settings saved.");
    }

    void LoadSoundSettings()
    {
        if (PlayerPrefs.HasKey("BackgroundSoundValue"))
        {
            backgroundSoundValue = PlayerPrefs.GetInt("BackgroundSoundValue");
            backgroundSoundSlider.value = backgroundSoundValue;
        }
        else
        {
            backgroundSoundValue = (int)backgroundSoundSlider.value;
        }

        if (PlayerPrefs.HasKey("EffectSoundValue"))
        {
            effectSoundValue = PlayerPrefs.GetInt("EffectSoundValue");
            effectSoundSlider.value = effectSoundValue;
        }
        else
        {
            effectSoundValue = (int)effectSoundSlider.value;
        }

        if (PlayerPrefs.HasKey("BackgroundSoundAmount"))
        {
            backgroundSoundAmount.text = PlayerPrefs.GetString("BackgroundSoundAmount");
        }

        if (PlayerPrefs.HasKey("EffectSoundAmount"))
        {
            effectSoundAmount.text = PlayerPrefs.GetString("EffectSoundAmount");
        }

        Debug.Log($"Loaded Background Sound Value: {backgroundSoundValue}");
        Debug.Log($"Loaded Effect Sound Value: {effectSoundValue}");
    }
}

 

새게임 시작 시

나머지를 초기화 후 저장

재시작 시

기존에 가지고 가야 할 정보들만 따로 저장하고 시작됨

 

이어하기는 기존의 데이터를 가져옴

 

나머지 도감 클릭시 준비카드 or 행동카드 도감 선택

환경설정 시나와야 할 UI 구성

 

 

https://cafe.naver.com/thisismysql

 

이것이MySQL이다 : 네이버 카페

한빛미디어 [이것이 MySQL이다] 카페입니다.

cafe.naver.com

 

위의 링크를 타고 글에 있는 이 링크를 클릭

 

https://drive.google.com/drive/folders/1KNAvefMzJpAurCj42-kTQmIoOvUTOe4T

 

10278_이것이 MySQL이다(2판) - Google Drive

이 폴더에 파일이 없습니다.이 폴더에 파일을 추가하려면 로그인하세요.

drive.google.com

 

movies 를 설치 후

 

 

해당 폴더들을 만들고 넣어준다.

 

그럼 이제 시작을 하기 위해한 자료들은 준비가 된 것이다.

 

이제 켜져있는 워크벤치를 꺼준다.

 

그 후 위와 같은 명령들로 해당 파일에 접근

 

여기서 수정해야 할 곳은 2개가 있다.

 

동영상을 업로드하기 위해 용량을 바꿔주는 것과

 

 

 

my.ini 파일을 저장후

net stop mysql을 하면 잠시 후 정지가 되고

net start mysql을 하면 다시 실행이 된다.

 

그리고 나서 워크 벤치를 키고 접속을 하면 적용이 된다.

 

CREATE DATABASE movieDB;

USE movieDB;
CREATE TABLE movietbl
(movie_id INT,
movie_title VARCHAR(30),
movie_director VARCHAR(20),
movir_star VARCHAR(20),
movie_script LONGTEXT,
movie_film LONGBLOB)
DEFAULT CHARSET = utf8mb4;

INSERT INTO movietbl VALUES (1,'쉰들러 리스트', '스필버그', '리암 니슨',
LOAD_FILE('C:/SQL/Movies/Schindler.txt'),
LOAD_FILE('C:/SQL/Movies/Schindler.mp4'));

SELECT * FROM movietbl;

SHOW variables LIKE 'max_allowed_packet';

SHOW variables LIKE 'secure_file_priv';

use moviedb;
TRUNCATE movietbl;
INSERT INTO movietbl VALUES (1, '쉰들러 리스트', '스필버그', '리암 니슨',
load_file('C:/SQL/Movies/Schindler.txt'), load_file('c:/sql/movies/Schindler.mp4'));
insert into movietbl values(2, '쇼생크 탈출', '프랭크 다라본트', '팀 로빈스',
load_file('c:/sql/movies/Shawshank.txt'), load_file('c:/sql/movies/Shawshank.mp4'));
insert into movietbl values(3, '라스트 모히칸', '마이클 만', '다니엘 데이 루이스',
Load_file('c:/sql/movies/mohican.txt'),load_file('c:/sql/movies/mohican.mp4'));

SELECT movie_script from movietbl where movie_id =1
INTO OUTFILE 'c:/sql/movies/schindler_out.txt'
LINES TERMINATED BY '\\n';

SHOW VARIABLES LIKE 'secure_file_priv';
SELECT * FROM movietbl;

use moviedb;
SELECT movie_film from movietbl where movie_id=3
into dumpfile 'c:/sql/movies/Mohican.mp4';

use sqldb;
create table pivottest
(uName CHAR(3),
season CHAR(2),
AMOUNT INT);
insert into pivotTest VALUES
('김범수', '겨울', 10), ('윤종신', '여름', 15), ('김범수', '가을', 25), ('김범수', '봄', 3),
('김범수', '봄', 37), ('윤종신', '겨울', 40), ('김범수', '여름', 14), ('김범수', '겨울', 22),
('윤종신', '여름', 64);

select * from pivotTest;

SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'sqldb' -- 여기에 데이터베이스 이름을 지정하세요
  AND TABLE_NAME = 'pivotTest'; -- 여기에 테이블 이름을 지정하세요

select uName,
	SUM(IF(season = '봄', amount, 0)) as '봄',
    sum(if(season = '여름', amount, 0)) as '여름',
    SUM(IF(season = '가을', amount, 0)) as '가을',
    SUM(IF(season = '겨울', amount, 0)) as '겨울',
    sum(amount) as '합계' from pivottest group by uName;
    
SELECT
    season,
    SUM(IF(uName = '김범수', amount, 0)) AS '김범수',
    SUM(IF(uName = '윤종신', amount, 0)) AS '윤종신'
FROM
    pivottest
GROUP BY
    season;

use sqldb;
SELECT JSON_OBJECT('name', name, 'height', height) as 'json 값'
from usertbl
where height >= 180;

SET @json = '{
    "usertbl": [
        {"name": "임재범", "height": 182},
        {"name": "이승기", "height": 182},
        {"name": "성시경", "height": 186}
    ]
}';

SELECT @JSON;

SELECT JSON_VALID(@JSOON) AS JSON_VALID;
SELECT JSON_SEARCH(@json, 'one', '성시경') AS JSON_SEARCH; -- 여기서 one대신에 all사용가능한데 one은 앞에 있는것 1개를 지칭
SELECT JSON_EXTRACT(@json, '$.usertbl[2].name') as JSON_EXTRACT;
SELECT JSON_INSERT(@json, '$.usertbl[0].mDate', '2009-09-09') AS JSON_INSERT;
SELECT JSON_REPLACE(@json, '$.usertbl[0].name', '홍길동') AS json_replace;
select json_remove(@json, '$.usertbl[0]') AS JSON_REMOVE;



-- JOIN
use sqldb;

SELECT *
FROM buytbl
INNER JOIN usertbl ON buytbl.userid = usertbl.userid
WHERE buytbl.userid = 'jyp';

select *
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by num;

-- 이렇게하면 userid가 모호해져서 오류가 난다.
select userid, name, prodname, addr, concat(mobile1, mobile2) as '연락처'
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by name;

select buytbl.userid, name, prodname, addr, concat(mobile1, mobile2) as '연락처'
from buytbl
inner join usertbl
on buytbl.userid = usertbl.userid
order by name;

-- 011-xxx-xxxx로 바꾸기
set @mobile1 = '011';
set @mobile2 = '2222222';
select concat(@mobile1, @mobile2);
-- case1
SELECT CONCAT(@mobile1, '-', left(@mobile2,3),'-', right(@mobile2,4));
-- case2
SELECT CONCAT(@mobile1, '-', SUBSTRING(@mobile2, 1, 3), '-', SUBSTRING(@mobile2, 4)) AS formatted_mobile;

+ Recent posts