Пример #1
0
        public override void OnInspectorGUI()
		{
			serializedObject.Update();

			SerializedProperty mesh = serializedObject.FindProperty("m_Mesh");

			if(mesh != null)
				EditorGUILayout.PropertyField(mesh);

			Mesh m = (Mesh) mesh.objectReferenceValue;

			if(m != null)
			{
				ModelSource source = PolyEditorUtility.GetMeshGUID(m);
                GameObject go = ((MeshFilter)serializedObject.targetObject).gameObject;
                bool isPBMesh = ProBuilderInterface.IsProBuilderObject(go);

                if (source == ModelSource.Scene && !isPBMesh)
				{
					if(GUILayout.Button(m_GCSaveButton))
						PolyEditorUtility.SaveMeshAsset(m);
				}
			}

			serializedObject.ApplyModifiedProperties();
		}
Пример #2
0
        /// <summary>
        /// Update the current state of the mesh preview.
        /// As AssetPreview API is asynchronous, we need to keep requesting the asset preview
        /// until we have it. Once texture is loaded, current state of the instance moves
        /// to Status.Loaded.
        /// </summary>
        internal void UpdatePreview()
        {
            switch (m_previewState)
            {
            case State.Loading:
                if (ProBuilderBridge.ProBuilderExists() && ProBuilderInterface.IsProBuilderObject(m_Asset as GameObject))
                {
                    m_PreviewTexture = GenerateProBuilderPreview();
                }
                else if (PolyEditorUtility.IsPolybrushObject(m_Asset as GameObject))
                {
                    m_PreviewTexture = GeneratePreview();
                }
                else
                {
                    m_PreviewTexture = AssetPreview.GetAssetPreview(m_Asset);
                }

                if (previewTexture != null)
                {
                    SetState(State.Loaded);
                }

                break;

            case State.Loaded:
                // Failsafe as AssetPreview can return white textures while loading
                // and erase that texture from memory once the right texture is available.
                if (m_PreviewTexture == null)
                {
                    SetState(State.Loading);
                }
                break;
            }
        }