- Home /
CustomScroll inherited from RectScroll, executing in edit mode
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 ?
Console: Debug.Log (Application.isPlaying);
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<CampaignItem>().SetAsActive ();
go.GetComponent<CampaignItem>().SetStars (5);
} else {
go.GetComponent<CampaignItem>().SetAsDisabled ();
go.GetComponent<CampaignItem>().SetStars (0);
}
}
}
Your answer
Follow this Question
Related Questions
Drawing a property in the inspector whose type could be one of several custom classes 2 Answers
Is there an event being fired off when the Inspector is being resized? 1 Answer
How do I implement Draggable Properties with custom Labels in Editor or PropertyDrawer? 1 Answer
OnInspectorGUI - Using the default Object Selection popup. 1 Answer
Create an Editor Window like Mecanim 1 Answer