Hello, I faced weird issue, that I can't understood.
I made CustomScroll class inherited from RectScroll.
Everything was okey to the moment, when my public variables disappeared from Inspector.
In my Custom class I made two things,
Instantiating Items at Start() and made LateUpdate() for Lerping content position to center on closest item.
For some reason after I exiting PlayMode in Editor, I can see items that was instantiated in PlayMode, they are not removed after. If I will run game few times, I will have list with a lot of duplicates.
After Debuging Start() function, I can see, that it executes two times, one in PlayMode, and after exit PlayMode in Editor.
Using new Unity2017.01.
Why is this happening, Is this issue ?
Edit1: If I understanding right, RectScroll have [ExecuteInEditMode] and functions that
`CampaignScroller.LateUpdate() hides inherited member UnityEngine.UI.ScrollRect.LateUpdate()z`
runs in Edit mode. Can I turned it off ?
![https://puu.sh/wJuzs/1524b8f83c.png][1]
Console: `Debug.Log (Application.isPlaying);`
![https://puu.sh/wJuJh/0bbaed4d21.png][2]
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CampaignScroller : ScrollRect {
int currentMapIndex = 0;
public Text currentName;
public GameObject itemPref;
void Start(){
Debug.Log (Application.isPlaying);
Initialize ();
}
void Initialize(){
foreach (CampaignManager.Mission mis in CampaignManager.missions) {
GameObject go = Instantiate (itemPref, content) as GameObject;
if ( mis.IsDone () ) {
go.GetComponent().SetAsActive ();
go.GetComponent().SetStars (5);
} else {
go.GetComponent().SetAsDisabled ();
go.GetComponent().SetStars (0);
}
}
}
[1]: https://puu.sh/wJuzs/1524b8f83c.png
[2]: https://puu.sh/wJuJh/0bbaed4d21.png
↧