Beispiel #1
0
    private void OnEnable()
    {
        try
        {
            CacheSerializedProperties();
            map     = (OnlineMaps)target;
            control = map.GetComponent <OnlineMapsControlBase>();

            savableItems = map.GetComponents <IOnlineMapsSavableComponent>().SelectMany(c => c.GetSavableItems()).OrderByDescending(s => s.priority).ThenBy(s => s.label).ToList();

            providers      = OnlineMapsProvider.GetProviders();
            providersTitle = providers.Select(p => p.title).ToArray();

            trafficProviders     = OnlineMapsTrafficProvider.GetProviders();
            cTrafficProviders    = trafficProviders.Select(p => new GUIContent(p.title)).ToArray();
            trafficProviderIndex = 0;
            for (int i = 0; i < trafficProviders.Length; i++)
            {
                if (trafficProviders[i].id == pTrafficProviderID.stringValue)
                {
                    trafficProviderIndex = i;
                    break;
                }
            }

            if (pTooltipTexture.objectReferenceValue == null)
            {
                pTooltipTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Tooltip.psd");
            }

            updateAvailableContent = new GUIContent("Update Available", OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\update_available.png"), "Update Available");
            wizardIconContent      = new GUIContent(OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\WizardIcon.png"), "Wizard");

            OnlineMapsUpdater.CheckNewVersionAvailable();

            mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
            providerIndex = mapType.provider.index;

            serializedObject.ApplyModifiedProperties();

            map.floatZoom = map.CheckMapSize(map.floatZoom);
        }
        catch (Exception e)
        {
            Debug.Log(e.Message + "\n" + e.StackTrace);
            //throw;
        }
    }
    private void OnEnable()
    {
        CacheSerializedProperties();
        api = (OnlineMaps)target;

        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = providers.Select(p => p.title).ToArray();

        if (string.IsNullOrEmpty(pMapType.stringValue))
        {
            pMapType.stringValue = OnlineMapsProvider.Upgrade(pProvider.enumValueIndex, pType.intValue);
        }

        trafficProviders     = OnlineMapsTrafficProvider.GetProviders();
        cTrafficProviders    = trafficProviders.Select(p => new GUIContent(p.title)).ToArray();
        trafficProviderIndex = 0;
        for (int i = 0; i < trafficProviders.Length; i++)
        {
            if (trafficProviders[i].id == pTrafficProviderID.stringValue)
            {
                trafficProviderIndex = i;
                break;
            }
        }

        if (pDefaultMarkerTexture.objectReferenceValue == null)
        {
            pDefaultMarkerTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Markers\\DefaultMarker.png");
        }
        if (pTooltipTexture.objectReferenceValue == null)
        {
            pTooltipTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Tooltip.psd");
        }

        updateAvailableContent = new GUIContent("Update Available", OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\update_available.png"), "Update Available");
        wizardIconContent      = new GUIContent(OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\WizardIcon.png"), "Wizard");

        OnlineMapsUpdater.CheckNewVersionAvailable();

        mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
        providerIndex = mapType.provider.index;

        serializedObject.ApplyModifiedProperties();
    }