using UnityEngine; using UnityEngine.UI; using System.Collections; using UnityEngine.EventSystems; public class ScrollViewAdapter : MonoBehaviour { public RectTransform prefab; public RectTransform content; public int curAction; ScEditor sce; Scenario sc; Manager man; Scrollbar scroll=null; public void Init() { sc = GameObject.Find("ScEditor").GetComponent().SC; man = GameObject.Find("Manager").GetComponent(); if (sc == null) { Debug.Log(" Panel2 Start: sc = null"); return; } sce = GameObject.Find("ScEditor").GetComponent(); sc = sce.SC; scroll = GameObject.Find("ActionsViewScrollbar").GetComponent(); //Debug.Log(" Start: sc.curModeSc.acts.Count = " + sc.curModeSc.acts.Count); InvokeRepeating("MyFixedUpdate", 0, 0.25f); } public void MyFixedUpdate() { if (sc == null) { //Debug.Log(" Panel2 FixedUpdate: sc == null "); return; } if (sc.curModeSc == null) { //Debug.Log(" Panel2 FixedUpdate: sc.curModeSc == null "); return; } if (scroll == null) return; if (sc.curModeSc.acts.Count == 0) return; int min; int cnt = sc.curModeSc.acts.Count; if (cnt > 16) cnt -= 16; min = Mathf.FloorToInt((1.0f - scroll.value) * cnt); for (int i = min; i < min+17; i++) //for (int i = 0; i < sc.curModeSc.acts.Count; i++) { GameObject go_ai = GameObject.Find("ActionItem" + i); if (go_ai == null) { //Debug.Log("ActionItem" + i + " not found. curModeActs = " + sc.curModeSc.acts.Count); continue; } Button btn = go_ai.GetComponent