Unity Rolly Vortex Game - (E12): Simple Shop System - (Part 2)
HTML-код
- Опубликовано: 26 ноя 2022
- Let's finish our shop system in unity!
● Playlist Link: bit.ly/3NLfNPQ
● Game Assets: bit.ly/3xiJMsy
♥ Don't Click This! : bit.ly/2Zi3vu9
♥ My Second Channel: bit.ly/3jvI8g6
--------------------------------------------------------------------
✅ My current Productivity Setup 👇:
● Gaming Headset: amzn.to/3HyXgp2
● Gaming Mouse: amzn.to/3ni4Ygp
● Best Webcam: amzn.to/44pVUqw
● Keyboard: amzn.to/3ALXB3M
● GPU: amzn.to/42mylNt
● CPU: amzn.to/44lOBjs
--------------------------------------------------------------------
FOLLOW ME:
● Facebook: / developer3.5pro
● Sketchfab: sketchfab.com/GDTitans
--------------------------------------------------------------------
► All content by GDTitans is 100% free. I believe that education should be freely available to everyone.
❤❤❤❤❤❤
Thanks for this tutorial😍
No worries
Very helpful video bro👍
Really appreciate it
Good job bro
hello
i followed your tutorial perfectely fine until the end;when i start collecting jems to bye skins-when i die all the collected jems reset to zero
Waiting or your next video for this series.
What do you suggest?
you still working on this project my unlock system is not working it would be grateful of you to check my code once
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BallSelector : MonoBehaviour
{
public GameObject[] ballSkins;
int selectedBall;
public Ball[] balls;
public Button[] buttons;
public Button unlockButton;
public void Awake()
{
int counter = 0;
foreach(Ball b in balls)
{
b.index = counter;
if(counter == 0)
b.isLocked = false;
else
{
if (PlayerPrefs.GetInt(b.index.ToString(), 1) == 1)
b.isLocked = true;
else
b.isLocked = false;
buttons[b.index].interactable = !b.isLocked;
}
counter++;
}
}
// Start is called before the first frame update
void Start()
{
selectedBall = PlayerPrefs.GetInt("SelectedBall", 0);
foreach(GameObject skin in ballSkins)
{
skin.SetActive(false);
}
ballSkins[selectedBall].SetActive(true);
}
// Update is called once per frame
public void Update()
{
if (PlayerPrefs.GetInt("TotalGems", 0) < 500)
unlockButton.interactable = false;
else
unlockButton.interactable = true;
}
public void ChangeBall(int index)
{
ballSkins[selectedBall].SetActive(false);
selectedBall = index;
ballSkins[selectedBall].SetActive(true);
PlayerPrefs.SetInt("SelectedBall", index);
}
public void Unlock()
{
List lockedBalls = new List();
foreach(Ball b in balls)
{
if(b.isLocked)
{
lockedBalls.Add(b);
}
if (lockedBalls.Count == 0)
return;
int randomBall = Random.Range(0, lockedBalls.Count);
int ballIndex = lockedBalls[randomBall].index;
balls[ballIndex].isLocked = false;
buttons[ballIndex].interactable = true;
PlayerPrefs.SetInt(ballIndex.ToString(), 0);
PlayerPrefs.SetInt("TotalGems", PlayerPrefs.GetInt("TotalGems") - 500);
buttons[ballIndex].onClick.Invoke();
}
}
}
Hey titan my scripts are same but unlocking system isnot working for me
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BallSelector : MonoBehaviour
{
public GameObject[] ballSkins;
int selectedBall;
public Ball[] balls;
public Button[] buttons;
public Button unlockButton;
public void Awake()
{
int counter = 0;
foreach(Ball b in balls)
{
b.index = counter;
if(counter == 0)
b.isLocked = false;
else
{
if (PlayerPrefs.GetInt(b.index.ToString(), 1) == 1)
b.isLocked = true;
else
b.isLocked = false;
buttons[b.index].interactable = !b.isLocked;
}
counter++;
}
}
// Start is called before the first frame update
void Start()
{
selectedBall = PlayerPrefs.GetInt("SelectedBall", 0);
foreach(GameObject skin in ballSkins)
{
skin.SetActive(false);
}
ballSkins[selectedBall].SetActive(true);
}
// Update is called once per frame
public void Update()
{
if (PlayerPrefs.GetInt("TotalGems", 0) < 500)
unlockButton.interactable = false;
else
unlockButton.interactable = true;
}
public void ChangeBall(int index)
{
ballSkins[selectedBall].SetActive(false);
selectedBall = index;
ballSkins[selectedBall].SetActive(true);
PlayerPrefs.SetInt("SelectedBall", index);
}
public void Unlock()
{
List lockedBalls = new List();
foreach(Ball b in balls)
{
if(b.isLocked)
{
lockedBalls.Add(b);
}
if (lockedBalls.Count == 0)
return;
int randomBall = Random.Range(0, lockedBalls.Count);
int ballIndex = lockedBalls[randomBall].index;
balls[ballIndex].isLocked = false;
buttons[ballIndex].interactable = true;
PlayerPrefs.SetInt(ballIndex.ToString(), 0);
PlayerPrefs.SetInt("TotalGems", PlayerPrefs.GetInt("TotalGems") - 500);
buttons[ballIndex].onClick.Invoke();
}
}
}
In unlock() function, the first value of b = 0 is unlock so count =0, it alaways return
Update free fire joystick character controller for mobile tutorial
Bro how to random spawn magnet or some power system in endless run game