getInstance() публичный статический Метод

public static getInstance ( ) : DecorationManager,
Результат DecorationManager,
Пример #1
0
    public void OnEnable()
    {
        selected      = Tools.current;
        Tools.current = Tool.None;

        if (!loaded)
        {
            string[] paths = AssetDatabase.GetAllAssetPaths();
            foreach (string path in paths)
            {
                if (path.StartsWith("Assets") || path.StartsWith("assets"))
                {
                    AssetDatabase.LoadAssetAtPath(path, typeof(IsoDecoration));
                }
            }

            IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList();
            foreach (var id in isoDecorations)
            {
                if (id.nCols * id.nRows > maxTile)
                {
                    maxTile = id.nCols * id.nRows;
                }
            }
            loaded = true;
        }

#if UNITY_EDITOR
        m_LastEditorUpdateTime    = Time.realtimeSinceStartup;
        EditorApplication.update += OnEditorUpdate;
#endif
    }
Пример #2
0
 public void setTexture(Texture2D texture)
 {
     this.realTexture = texture;
     DecorationManager.getInstance().update(this);
 }
Пример #3
0
    public void OnInspectorGUI()
    {
        GUIStyle style = new GUIStyle();

        EditorGUILayout.HelpBox("Press left button to put the textures over the faces of the cell. Hold shift and press left button to copy the current texture of the hovering face.", MessageType.None);
        EditorGUILayout.Space();

        parallelDecoration = EditorGUILayout.Toggle("Draw Parallel", parallelDecoration);
        EditorGUILayout.Space();

        autoanimate = EditorGUILayout.Toggle("Auto Animate", autoanimate);

        if (autoanimate)
        {
            FrameRate = float.Parse(EditorGUILayout.TextField("Frame Rate:", FrameRate.ToString()));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Frame Secuence:", GUIStyle.none, titleStyle);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.HelpBox("Let the frame secuence list empty if you want to use the default frame loop.", MessageType.None);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginVertical();

            GUIContent btt = new GUIContent("Add Frame");
            Rect       btr = GUILayoutUtility.GetRect(btt, style);
            if (GUI.Button(btr, btt))
            {
                if (FrameSecuence == null)
                {
                    FrameSecuence = new int[0];
                }
                int[] tmpFrameSecuence = new int[FrameSecuence.Length + 1];
                for (int i = 0; i < FrameSecuence.Length; i++)
                {
                    tmpFrameSecuence[i] = FrameSecuence[i];
                }
                tmpFrameSecuence[tmpFrameSecuence.Length - 1] = 0;
                FrameSecuence = tmpFrameSecuence;
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();
            btt = new GUIContent("Remove Frame");
            btr = GUILayoutUtility.GetRect(btt, style);
            if (GUI.Button(btr, btt))
            {
                if (FrameSecuence.Length > 0)
                {
                    if (FrameSecuence == null)
                    {
                        FrameSecuence = new int[0];
                    }
                    int[] tmpFrameSecuence = new int[FrameSecuence.Length - 1];
                    for (int i = 0; i < FrameSecuence.Length - 1; i++)
                    {
                        tmpFrameSecuence[i] = FrameSecuence[i];
                    }
                    FrameSecuence = tmpFrameSecuence;
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            if (FrameSecuence != null)
            {
                for (int i = 0; i < FrameSecuence.Length; i++)
                {
                    FrameSecuence[i] = int.Parse(EditorGUILayout.TextField(i.ToString(), FrameSecuence[i].ToString()));
                }
            }
        }
        EditorGUILayout.Space();

        EditorGUILayout.PrefixLabel("Decoration Objects", GUIStyle.none, titleStyle);

        GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 0.5f);

        EditorGUILayout.BeginVertical("Box");

        IsoDecoration[] isoDecorations = DecorationManager.getInstance().textureList();

        int   maxTextures  = 8;
        float anchoTextura = (Screen.width - 30) / maxTextures;

        if (isoDecorations.Length > maxTextures * LTSS)
        {
            scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(anchoTextura * LTSS));
        }

        Event e = Event.current;

        int currentTexture = 0;

        foreach (IsoDecoration it in isoDecorations)
        {
            if (it.getTexture() == null)
            {
                continue;
            }

            if (currentTexture == 0)
            {
                EditorGUILayout.BeginHorizontal();
            }

            Rect auxRect = GUILayoutUtility.GetRect(anchoTextura, anchoTextura);
            Rect border  = new Rect(auxRect);
            auxRect.x += 2; auxRect.y += 2; auxRect.width -= 4; auxRect.height -= 4;

            if (e.isMouse && border.Contains(e.mousePosition))
            {
                if (e.type == EventType.mouseDown)
                {
                    paintingIsoDecoration = it;
                    this.Repaint          = true;
                }
            }

            if (it == paintingIsoDecoration)
            {
                EditorGUI.DrawRect(border, Color.yellow);
            }
            GUI.DrawTexture(auxRect, it.getTexture());

            currentTexture++;
            if (currentTexture == maxTextures)
            {
                EditorGUILayout.EndHorizontal(); currentTexture = 0;
            }
        }

        if (currentTexture != 0)
        {
            GUILayoutUtility.GetRect((maxTextures - currentTexture) * anchoTextura, anchoTextura);
            EditorGUILayout.EndHorizontal();
        }

        if (isoDecorations.Length > maxTextures * LTSS)
        {
            EditorGUILayout.EndScrollView();
        }


        EditorGUILayout.EndVertical();
    }