Tool that makes it easy to drag prefabs into it to "cache" them for ease of use.
Inheritance: EditorWindow
Exemple #1
0
    /// <summary>
    /// Set up everything necessary to preview a UI object.
    /// </summary>

    static bool SetupPreviewFor3D(Camera cam, GameObject root, GameObject child, UISnapshotPoint point)
    {
        Renderer[] rens = child.GetComponentsInChildren <Renderer>();
        if (rens.Length == 0)
        {
            return(false);
        }

        Vector3 camDir   = new Vector3(-0.25f, -0.35f, -0.5f);
        Vector3 lightDir = new Vector3(-0.25f, -0.5f, -0.25f);

        camDir.Normalize();
        lightDir.Normalize();

        // Determine the bounds of the model
        Renderer ren    = rens[0];
        Bounds   bounds = ren.bounds;
        int      mask   = (1 << ren.gameObject.layer);

        for (int i = 1; i < rens.Length; ++i)
        {
            ren   = rens[i];
            mask |= (1 << ren.gameObject.layer);
            bounds.Encapsulate(ren.bounds);
        }

        // Set the camera's properties
        cam.cullingMask = mask;
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
        cam.isOrthoGraphic = true;
#else
        cam.orthographic = true;
#endif
        cam.transform.position = bounds.center;
        cam.transform.rotation = Quaternion.LookRotation(camDir);

        float objSize = bounds.size.magnitude;
        if (point != null)
        {
            SetupSnapshotCamera(child, cam, point);
        }
        else
        {
            SetupSnapshotCamera(child, cam, objSize, objSize * 0.4f, -objSize, objSize);
        }

        // Deactivate all scene lights
        DeactivateLights();

        // Create our own light
        GameObject lightGO = new UIPrefabTool().AddChild(root);
        Light      light   = lightGO.AddComponent <Light>();
        light.type               = LightType.Directional;
        light.shadows            = LightShadows.None;
        light.color              = Color.white;
        light.intensity          = 0.65f;
        light.transform.rotation = Quaternion.LookRotation(lightDir);
        light.cullingMask        = mask;
        return(true);
    }
Exemple #2
0
    /// <summary>
    /// Clean up all textures.
    /// </summary>

    void OnDisable()
    {
        instance = null;
        foreach (Item item in mItems)
        {
            DestroyTexture(item);
        }
        Save();
    }
Exemple #3
0
    /// <summary>
    /// Clean up all textures.
    /// </summary>

    void OnDisable()
    {
        instance = null;
        {
            // foreach(var item in mItems)
            var __enumerator1 = (mItems).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var item = (Item)__enumerator1.Current;
                DestroyTexture(item);
            }
        }
        Save();
    }
Exemple #4
0
    /// <summary>
    /// Initialize everything.
    /// </summary>

    void OnEnable()
    {
        instance = this;

        Load();

        mContent                 = new GUIContent();
        mStyle                   = new GUIStyle();
        mStyle.alignment         = TextAnchor.MiddleCenter;
        mStyle.padding           = new RectOffset(2, 2, 2, 2);
        mStyle.clipping          = TextClipping.Clip;
        mStyle.wordWrap          = true;
        mStyle.stretchWidth      = false;
        mStyle.stretchHeight     = false;
        mStyle.normal.textColor  = UnityEditor.EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.5f) : new Color(0f, 0f, 0f, 0.5f);
        mStyle.normal.background = null;
    }
	/// <summary>
	/// Initialize everything.
	/// </summary>

	void OnEnable ()
	{
		instance = this;

		Load();

		mContent = new GUIContent();
		mStyle = new GUIStyle();
		mStyle.alignment = TextAnchor.MiddleCenter;
		mStyle.padding = new RectOffset(2, 2, 2, 2);
		mStyle.clipping = TextClipping.Clip;
		mStyle.wordWrap = true;
		mStyle.stretchWidth = false;
		mStyle.stretchHeight = false;
		mStyle.normal.textColor = UnityEditor.EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.5f) : new Color(0f, 0f, 0f, 0.5f);
		mStyle.normal.background = null;
	}
	/// <summary>
	/// Clean up all textures.
	/// </summary>

	void OnDisable ()
	{
		instance = null;
		foreach (Item item in mItems) DestroyTexture(item);
		Save();
	}