You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using System.Collections ;
using System.Collections.Generic ;
using UnityEngine ;
using XWFramework.UI ;
using UnityEngine.UI ;
using System ;
public class TogglePaneExample : UIPanel
{
[Header("子物体")]
public GameObject toggles ;
public Text title ;
public Button emitBtn ;
protected ToggleGroup toggleGroup ;
[NonSerialized]
public bool questionType ; //当前题目类型 false代表单选, true代表多选
protected bool [ ] answers = new bool [ 4 ] ;
protected override void Awake ( )
{
type = UIType . Toggle ;
base . Awake ( ) ;
toggleGroup = GetComponent < ToggleGroup > ( ) ;
for ( int i = 0 ; i < toggles . transform . GetComponentsInChildren < Toggle > ( ) . Length ; i + + )
{
var id = i ;
toggles . transform . GetChild ( i ) . GetComponent < Toggle > ( ) . onValueChanged . AddListener ( ( value ) = > {
answers [ id ] = value ;
} ) ;
}
emitBtn . onClick . AddListener ( EmitCallBack ) ;
}
protected override void Init ( )
{
InintToggle ( ) ;
UpdateShow ( ) ;
}
protected virtual void InintToggle ( ) {
for ( int i = 0 ; i < answers . Length ; i + + )
{
answers [ i ] = false ;
}
for ( int i = 0 ; i < toggles . transform . GetComponentsInChildren < Toggle > ( ) . Length ; i + + )
{
toggles . transform . GetChild ( i ) . GetComponent < Toggle > ( ) . isOn = false ;
}
}
public virtual void UpdateShow ( ) {
}
public virtual void EmitCallBack ( ) {
}
}