Thursday, 29 December 2016

How to Delete Canvas Panel Child Objects

1. You need to calculate the number of child objects
2. Use loops to get child one by one delete the using Destroy method.



Method 1 :-
========
if (InfoButtonPanel.transform.childCount >= 0) {
     Transform[] allChildren = InfoButtonPanel.transform.GetComponentsInChildren<Transform>();
foreach (var item in allChildren) {
Destroy (item.transform.gameObject);
}
}


Method 2 :-
========
if (InfoButtonPanel.transform.childCount >= 0) {
     for (int i = 0; i < InfoButtonPanel.transform.childCount; i++) {
    GameObject.Destroy(InfoButtonPanel.transform.GetChild(i).gameObject);
}
}

Canvas Button On Click Code

Button.onClick.AddListener


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

public class ButtonController : MonoBehaviour {
public Button myButton;

void Awake()
{
myButton = GetComponent<Button>();
myButton.onClick.AddListener( () => {myFunctionForOnClickEvent("stringValue", 4.5f);} );
}

void myFunctionForOnClickEvent(string arg1, float arg2)
{
print(arg1 + ", " + arg2.ToString());
}
}



You can also remove Listener() using below code on Destroy Function

void Destroy()
{
myButton.onClick.RemoveListener(() => {myFunctionForOnClickEvent("stringValue", 4.5f);});
}



Monday, 26 December 2016

how to get key-hashes for android facebook app


Here is the command :-
=================
Open you Command Prompt  and run below command to get keyhash
Note* :- You need to enter your key store password

keytool -exportcert -alias bowmen -keystore "C:\Users\Red&Black\Downloads\bowmenuserkeystore.keystore" | "C:\openssl\bin\openssl" sha1 -binary |"C:\openssl\bin\openssl" base64

You can get openssl from below link :-
===============================
https://code.google.com/archive/p/openssl-for-windows/downloads