Esempio n. 1
0
 public WindowGroup this[WindowGroupType type]
 {
     get
     {
         groups.TryGetValue(type.GetHashCode(), out WindowGroup value);
         return(value);
     }
 }
Esempio n. 2
0
 public void AddGroup(WindowGroupType groupType, WindowGroup windowGroup)
 {
     if (groups == null)
     {
         groups = new Dictionary <int, WindowGroup>();
     }
     groups[groupType.GetHashCode()] = windowGroup;
 }
Esempio n. 3
0
    /// <summary>
    /// Create window by group type and prefab path
    /// </summary>
    /// <param name="groupType">Window group type</param>
    /// <param name="path">Prefab path</param>
    /// <returns>The window handle</returns>
    private Window CreateWindow(WindowGroupType groupType, string path)
    {
        var root   = WindowRootManager.WindowObjectMap[groupType];
        var prefab = Resources.Load <GameObject>(path);

        if (prefab == null)
        {
            Logger.LogError("Could not find window from groupType - " + groupType + ", path - " + path);
            return(null);
        }

        // This is importance, Awake / OnEnable should not be called until Show is get called.
        prefab.SetActive(false);
        var child  = NGUITools.AddChild(root, prefab);
        var window = child.GetComponent <Window>();

        window.Path        = path;
        window.WindowGroup = groupType;
        return(window);
    }
    void OnGUI()
    {
        userManual = GUILayout.TextArea(userManual, "Label");

        EditorGUILayout.Space();

        GUI.enabled = false;
        template    = EditorGUILayout.ObjectField("Template: ", template, typeof(TextAsset), false) as TextAsset;
        GUI.enabled = true;

        prefabName  = EditorGUILayout.TextField("Name: ", prefabName);
        windowGroup = (WindowGroupType)EditorGUILayout.EnumPopup("Window Group: ", windowGroup);
        var templatePath = string.Format("{0}/{1}{2}", TemplateBasePath, TemplateWindow, Utils.ScriptExtension);

        template = AssetDatabase.LoadMainAssetAtPath(templatePath) as TextAsset;

        const bool allowSceneObjects = true;

        prefabGameObject = EditorGUILayout.ObjectField("Game Object: ", prefabGameObject, typeof(GameObject), allowSceneObjects) as GameObject;

        if (GUILayout.Button("Generator Prefab"))
        {
            buttonPressed = true;

            GeneratePrefab();

            xmlGenerator.GenerateMappingFile();
        }

        if (buttonPressed && !EditorApplication.isCompiling)
        {
            buttonPressed = false;

            var specificWindowName = string.Format("{0}Window", prefabName);
            UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(generatedPrefab, "Assets/MarkusCommon/Scripts/WindowManager/Editor/WindowPrefabGeneratorWindow.cs (171,13)", specificWindowName);
        }

        EditorGUILayout.Space();

        log = GUILayout.TextArea(log, "Label");
    }
Esempio n. 5
0
 /// <summary>
 /// Show windows by group type.
 /// </summary>
 /// <param name="groupType">Group type</param>
 /// <param name="show">Flag indicates if show or hide</param>
 public void Show(WindowGroupType groupType, bool show)
 {
     if ((int)groupType == Utils.Invalid || !Mapping.LayerPathMap.ContainsKey(groupType))
     {
         Logger.LogError("Could not contain group type - " + groupType +
                         ", please double check with WindowGroupType, that's all we have.");
         return;
     }
     if (!windowMap.ContainsKey(groupType))
     {
         Logger.LogWarning("The window group type - " + groupType +
                           ", has already closed, we need not call show window to close them.");
         return;
     }
     windowMap[groupType].ForEach(win =>
     {
         if (win.gameObject.activeSelf != show)
         {
             win.gameObject.SetActive(show);
         }
     });
 }
    private IEnumerator DoFade(WindowGroupType group, bool fadeIn, FadeComplete onFadeComplete)
    {
        var tweenAlpha = WindowAlphaTweenMap[group];
        tweenAlpha.ResetToBeginning();
        if (fadeIn)
        {
            tweenAlpha.PlayForward();
        }
        else
        {
            tweenAlpha.PlayReverse();
        }

        var lastWindow = WindowManager.Instance.CurrentWindowMap[group];
        Logger.LogWarning("DoFade: " + group + ", window: " + lastWindow.name);

        yield return new WaitForSeconds(tweenAlpha.duration);

        if (onFadeComplete != null)
        {
            onFadeComplete(lastWindow);
        }
    }
 private void InitAlphaTween(Transform layerTrans, WindowGroupType groupType)
 {
     var tweenAlpha = layerTrans.GetComponent<TweenAlpha>() ??
                      layerTrans.gameObject.AddComponent<TweenAlpha>();
     tweenAlpha.from = 0f;
     tweenAlpha.to = 1f;
     tweenAlpha.duration = FadeInDuration;
     tweenAlpha.enabled = false;
     WindowAlphaTweenMap[groupType] = tweenAlpha;
 }
 public void FadeOut(WindowGroupType group, FadeComplete onFadeComplete = null)
 {
     StartCoroutine(DoFade(group, false, onFadeComplete));
 }
 public void FadeIn(WindowGroupType group, FadeComplete onFadeComplete = null)
 {
     StartCoroutine(DoFade(group, true, onFadeComplete));
 }
    void OnGUI()
    {
        userManual = GUILayout.TextArea(userManual, "Label");
        
        EditorGUILayout.Space();

        GUI.enabled = false;
        template = EditorGUILayout.ObjectField("Template: ", template, typeof(TextAsset), false) as TextAsset;
        GUI.enabled = true;

        prefabName = EditorGUILayout.TextField("Name: ", prefabName);
        windowGroup = (WindowGroupType)EditorGUILayout.EnumPopup("Window Group: ", windowGroup);
        var templatePath = string.Format("{0}/{1}{2}", TemplateBasePath,
            (windowGroup == WindowGroupType.TabPanel) ? TemplateTabWindow : TemplateWindow, Utils.ScriptExtension);

        template = AssetDatabase.LoadMainAssetAtPath(templatePath) as TextAsset;
        Debug.Log(templatePath);

        const bool allowSceneObjects = true;
        prefabGameObject = EditorGUILayout.ObjectField("Game Object: ", prefabGameObject, typeof(GameObject), allowSceneObjects) as GameObject;

        if (GUILayout.Button("Generator Prefab"))
        {
            buttonPressed = true;

            GeneratePrefab();

            xmlGenerator.GenerateMappingFile();
        }

        if (buttonPressed && !EditorApplication.isCompiling)
        {
            buttonPressed = false;

            var specificWindowName = string.Format("{0}Window", prefabName);
            generatedPrefab.AddComponent(specificWindowName);
        }

        EditorGUILayout.Space();

        log = GUILayout.TextArea(log, "Label");
    }