fbpx

Loading...

(Just one moment)

Free Code

[vc_row][vc_column][vc_video link=”https://youtu.be/Aju5GF4YH4I” el_width=”50″ align=”center” title=”Best Mobile Ads”][vc_column_text]

Mobile Ads (GDPR Compliant)

The asset = https://assetstore.unity.com/packages/tools/integration/mobile-ads-gdpr-compliant-102892

 

[/vc_column_text][vc_column_text][dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”no” copy-text=”Copy Code” copy-confirmed=”Copied”]

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class AdScene : MonoBehaviour
{
  

    public GameObject panelQ, panelA;

    void Start()
    {
        if (Advertisements.Instance.UserConsentWasSet() == false)
        {
    
            
                panelQ.SetActive(true);
                

            }
            else
            {
                panelQ.SetActive(false);

                StartCoroutine(StartGame());
            }
     }
    
        public void Random()
        {
            Advertisements.Instance.SetUserConsent(false);
            panelQ.SetActive(false);
            StartCoroutine(StartGame());

           
        }
        public void Relevant()
        {
            Advertisements.Instance.SetUserConsent(true);
            panelQ.SetActive(false);
            StartCoroutine(StartGame());
           
        }

        IEnumerator StartGame()
        {
            panelA.SetActive(true);

            Advertisements.Instance.Initialize();

            yield return new WaitForSeconds(2);
            SceneManager.LoadScene(1);
    }
}

[/dm_code_snippet][/vc_column_text][vc_video link=”https://youtu.be/GgVH6Ve5quU” el_width=”50″ align=”center” title=”My Free Sound Manager”][/vc_column][/vc_row][vc_row][vc_column][ia_heading]Info[/ia_heading][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” copy-text=”Copy Code” copy-confirmed=”Copied”]

using UnityEngine;
using System.Collections;

[System.Serializable]
public class S
{
	public enum FontName {

		S0,
		S1,
		S2,
		S3,
		S4,
		S5,
		S6,
		S7,
		S8,
		S9,
		S10,
		S11,
		S12,
		S13,
		S14,
		S15,
		S16,
		S17,
		S18,
		S19,
		S20,
		S21,
		S22,
		S23,
		S24,
		

	};
	public AudioClip sound;



	public bool toggle;
}

[/dm_code_snippet][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][ia_heading]Mute[/ia_heading][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#fff” theme=”dark” language=”clike” wrapped=”no” copy-text=”Copy Code” copy-confirmed=”Copied”]

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Mute : MonoBehaviour
{
    public Sprite soundOn, soundOff, musicOn, musicOff;
    public Image soundButton, musicButton;

    void Update()
    {
        if (PlayerPrefs.GetInt("music") != 2)
        {
            musicButton.sprite = musicOn;
        }
        else
        {
            musicButton.sprite = musicOff;
        }

        if (PlayerPrefs.GetInt("sound") != 2)
        {
            soundButton.sprite = soundOn;
        }
        else
        {
            soundButton.sprite = soundOff;
        }
    }
    public void MusicMute()
    {
        SoundManager.instance.MuteMusic();
    }
    public void SoundMute()
    {
        SoundManager.instance.MuteSound();
    }
}

[/dm_code_snippet][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][ia_heading]SoundManager[/ia_heading][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”no” copy-text=”Copy Code” copy-confirmed=”Copied”]

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoundManager : MonoBehaviour
{

public List<S> soundsList = new List<S>();
public List<string> note = new List<string>();
public AudioClip menuMusic, gameMusic, gameMusic1, gameMusic2;
public static SoundManager instance = null;
public AudioSource musicSource, soundSource, soundSoure1;
bool startLoop;
int musicID;

void Awake()
{

DontDestroyOnLoad(gameObject);

if (instance == null)

instance = this;

else if (instance != this)

Destroy(gameObject);
}

public void MuteSound()
{
if (PlayerPrefs.GetInt(“sound”) != 2)
{
PlayerPrefs.SetInt(“sound”, 2);
}
else
{
PlayerPrefs.SetInt(“sound”, 0);
}
SetMutes();

}
public void MuteMusic()
{
if (PlayerPrefs.GetInt(“music”) != 2)
{
PlayerPrefs.SetInt(“music”, 2);
}
else
{
PlayerPrefs.SetInt(“music”, 0);
}
SetMutes();

}
private void SetMutes()
{
if (PlayerPrefs.GetInt(“music”) != 2)
{
musicSource.mute = false;
}
else
{
musicSource.mute = true;
}
if (PlayerPrefs.GetInt(“sound”) != 2)
{
soundSource.mute = false;
soundSoure1.mute = false;
}
else
{
soundSource.mute = true;
soundSoure1.mute = true;
}
}
public void PlayMusic(int menu0Game1)
{
musicID = menu0Game1;
startLoop = true;
SetMutes();

if (menu0Game1 == 0)
{
musicSource.clip = menuMusic;
}
else
{
int i = Random.Range(1, 100);
if (i <= 33)
{
musicSource.clip = gameMusic;
}
else if (i > 33 && i <= 66)
{
musicSource.clip = gameMusic1;
}
else if (i > 66 && i <= 100)
{
musicSource.clip = gameMusic2;
}
}
musicSource.Play();
}
void FixedUpdate()
{
if (gameMusic != null)
{
if (!musicSource.isPlaying && startLoop)
{
PlayMusic(musicID);
}
}
}
public void PlaySound(S.FontName fontName)
{
SetMutes();
switch (fontName.ToString())
{
case “S0”:
SoundAllocator(soundsList[0].sound);
break;
case “S1”:
SoundAllocator(soundsList[1].sound);
break;
case “S2”:
SoundAllocator(soundsList[2].sound);
break;
case “S3”:
SoundAllocator(soundsList[3].sound);
break;
case “S4”:
SoundAllocator(soundsList[4].sound);
break;
case “S5”:
SoundAllocator(soundsList[5].sound);
break;
case “S6”:
SoundAllocator(soundsList[6].sound);
break;
case “S7”:
SoundAllocator(soundsList[7].sound);
break;
case “S8”:
SoundAllocator(soundsList[8].sound);
break;
case “S9”:
SoundAllocator(soundsList[9].sound);
break;
case “S10”:
SoundAllocator(soundsList[10].sound);
break;
case “S11”:
SoundAllocator(soundsList[11].sound);
break;
case “S12”:
SoundAllocator(soundsList[12].sound);
break;
case “S13”:
SoundAllocator(soundsList[13].sound);
break;
case “S14”:
SoundAllocator(soundsList[14].sound);
break;
case “S15”:
SoundAllocator(soundsList[15].sound);
break;
case “S16”:
SoundAllocator(soundsList[16].sound);
break;
case “S17”:
SoundAllocator(soundsList[17].sound);
break;
case “S18”:
SoundAllocator(soundsList[18].sound);
break;
case “S19”:
SoundAllocator(soundsList[19].sound);
break;
case “S20”:
SoundAllocator(soundsList[20].sound);
break;
case “S21”:
SoundAllocator(soundsList[21].sound);
break;
case “S22”:
SoundAllocator(soundsList[22].sound);
break;
case “S23”:
SoundAllocator(soundsList[23].sound);
break;
case “S24”:
SoundAllocator(soundsList[24].sound);
break;
default:
SoundAllocator(soundsList[0].sound);
break;
}
}
void SoundAllocator(AudioClip clip, int iii = 0)
{
if (!soundSource.isPlaying)
{
if (iii == 3)
{
soundSource.pitch = Random.Range(1.0f, 3.0f);
}
else
{
soundSource.pitch = 1;
}
soundSource.clip = clip;
soundSource.Play();

}
else if (!soundSoure1.isPlaying)
{
if (iii == 3)
{
soundSoure1.pitch = Random.Range(1.0f, 3.0f);
}
else
{
soundSoure1.pitch = 1;
}
soundSoure1.clip = clip;
soundSoure1.Play();
}
else
{
if (iii == 3)
{
soundSource.pitch = Random.Range(1.0f, 3.0f);
}
else
{
soundSource.pitch = 1;
}
soundSource.clip = clip;
soundSource.Play();
}
}

}

[/dm_code_snippet][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][ia_heading]SoundManagerEditor[/ia_heading][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][dm_code_snippet background=”yes” background-mobile=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”no” copy-text=”Copy Code” copy-confirmed=”Copied”]

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

[CustomEditor(typeof(SoundManager))]
public class SoundManagerEditor : Editor
{
	SoundManager _target;

    private S _current;
	public int listNum;


	public override void OnInspectorGUI()
	{
		_target = (SoundManager)target;

		if (_target.soundsList.Count > 24)
		{
			for (int i = 0; i < 25; i++)
			{
				EditorGUILayout.Separator();
				DrawAudioField(i);

				EditorGUILayout.Separator();
			}
		}
		else
		{
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");
			_target.note.Add("note");

			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
			_target.soundsList.Add(_current);
		}

		EditorGUILayout.Separator();
		EditorGUILayout.Separator();
		DrawMusicField();

		EditorGUILayout.Separator();
		DrawMusic1Field();

		EditorGUILayout.Separator();
		DrawMusic2Field();

		EditorGUILayout.Separator();
		DrawMusic3Field();

		EditorGUILayout.Separator();
		DrawAudioSourceField();
		EditorGUILayout.Separator();
		DrawAudioSource1Field();
		EditorGUILayout.Separator();
		DrawAudioSource2Field();
		EditorGUILayout.Separator();


		if (GUI.changed)
			EditorUtility.SetDirty(target);
	}


	public void DrawAudioField(int i)
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("s" + i.ToString(), GUILayout.MaxWidth(28));
		_target.note[i] = EditorGUILayout.TextField(_target.note[i]);
		_target.soundsList[i].sound = (AudioClip)EditorGUILayout.ObjectField(_target.soundsList[i].sound, typeof(AudioClip),true);
		EditorGUILayout.EndHorizontal();
	}

	public void DrawMusicField()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Menu Music NEEDED");
		_target.menuMusic = (AudioClip)EditorGUILayout.ObjectField(_target.menuMusic, typeof(AudioClip), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawMusic1Field()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Game Music 0 NEEDED");
		_target.gameMusic = (AudioClip)EditorGUILayout.ObjectField(_target.gameMusic, typeof(AudioClip), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawMusic2Field()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Game Music 1 NEEDED");
		_target.gameMusic1 = (AudioClip)EditorGUILayout.ObjectField(_target.gameMusic1, typeof(AudioClip), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawMusic3Field()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Game Music 2 NEEDED");
		_target.gameMusic2 = (AudioClip)EditorGUILayout.ObjectField(_target.gameMusic2, typeof(AudioClip), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawAudioSourceField()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Music AudioS NEEDED");
		_target.musicSource = (AudioSource)EditorGUILayout.ObjectField(_target.musicSource, typeof(AudioSource), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawAudioSource1Field()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Sound AudioS NEEDED");
		_target.soundSource = (AudioSource)EditorGUILayout.ObjectField(_target.soundSource, typeof(AudioSource), true);
		EditorGUILayout.EndHorizontal();
	}
	public void DrawAudioSource2Field()
	{
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Sound AudioS NEEDED");
		_target.soundSoure1 = (AudioSource)EditorGUILayout.ObjectField(_target.soundSoure1, typeof(AudioSource), true);
		EditorGUILayout.EndHorizontal();
	}
}

[/dm_code_snippet][/vc_column_text][/vc_column][/vc_row]

By using this website you agree to accept our Privacy Policy and Terms & Conditions

Facebook
Twitter
YouTube
Instagram