MIF_E31222344/Malukuu/Assets/Script/reset.cs

77 lines
1.9 KiB
C#

// using System.Collections;
// using System.Collections.Generic;
// using UnityEngine;
// public class reset : MonoBehaviour
// {
// public GameObject parent_puzzle, senyum;
// // Start is called before the first frame update
// void Start()
// {
// }
// void OnMouseUp()
// {
// for(int i=0; i < 4; i++){
// parent_puzzle.transform.GetChild(i).GetComponent<drag_puzzle> ().on_tempel = false;
// parent_puzzle.transform.GetChild(i).GetComponent<drag_puzzle> ().on_pos = false;
// parent_puzzle.transform.GetChild(i).position = parent_puzzle.transform.GetChild(i).GetComponent<drag_puzzle> ().pos_awal;
// parent_puzzle.transform.GetChild(i).localScale = parent_puzzle.transform.GetChild(i).GetComponent<drag_puzzle> ().scale_awal;
// }
// senyum.SetActive (false);
// parent_puzzle.GetComponent<feedback>().selesai = false;
// }
// // Update is called once per frame
// void Update()
// {
// }
// }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class reset : MonoBehaviour
{
public GameObject parent_puzzle, senyum;
void OnMouseUp()
{
int jumlahChild = parent_puzzle.transform.childCount;
for (int i = 0; i < jumlahChild; i++)
{
Transform child = parent_puzzle.transform.GetChild(i);
drag_puzzle puzzle = child.GetComponent<drag_puzzle>();
if (puzzle != null)
{
puzzle.on_tempel = false;
puzzle.on_pos = false;
child.position = puzzle.pos_awal;
child.localScale = puzzle.scale_awal;
}
}
if (senyum != null)
{
senyum.SetActive(false);
}
feedback fb = parent_puzzle.GetComponent<feedback>();
if (fb != null)
{
fb.selesai = false;
}
}
}