当前位置: 首页>>代码示例>>C#>>正文


C# Material.CopyPropertiesFromMaterial方法代码示例

本文整理汇总了C#中UnityEngine.Material.CopyPropertiesFromMaterial方法的典型用法代码示例。如果您正苦于以下问题:C# Material.CopyPropertiesFromMaterial方法的具体用法?C# Material.CopyPropertiesFromMaterial怎么用?C# Material.CopyPropertiesFromMaterial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Material的用法示例。


在下文中一共展示了Material.CopyPropertiesFromMaterial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

		// Use this for initialization
		void Start () {
			currentOutsideMaterial = new Material (dissolveMaterial.shader);
			currentOutsideMaterial.CopyPropertiesFromMaterial(dissolveMaterial);

			currentGlassMaterial = new Material (glassMaterial.shader);
			currentGlassMaterial.CopyPropertiesFromMaterial(glassMaterial);

			foreach (Transform t in outside.GetComponentsInChildren<Transform>()) {

				var renderer = t.gameObject.GetComponent<SpriteRenderer>();
				if (renderer != null) {
					
					if (t.CompareTag(Tags.Glass)){
						renderer.material = currentGlassMaterial;
					} else {
						renderer.material = currentOutsideMaterial;
					}


				}

		
			}

		}
开发者ID:Kundara,项目名称:project1,代码行数:26,代码来源:Building.cs

示例2: CreateMaterial

	static void CreateMaterial (GameObject go) {
		// Create a simple material asset
		if (go.GetComponent<Renderer>() != null)
		{
			Material material = new Material(go.GetComponent<Renderer>().sharedMaterial);
			material.CopyPropertiesFromMaterial(go.GetComponent<Renderer>().sharedMaterial);
			go.GetComponent<Renderer>().sharedMaterial = material;
			MaterialPropertyBlock block = new MaterialPropertyBlock();
			go.GetComponent<Renderer>().GetPropertyBlock(block);
			#if UNITY_EDITOR
			if(!Directory.Exists("Assets/Materials")) {
				AssetDatabase.CreateFolder("Assets", "Materials");
				AssetDatabase.Refresh();
			}

			string textureName = null;
			if (block.GetTexture(0).name != null) {
				textureName = block.GetTexture(0).name;
			} else {
				textureName = material.mainTexture.name;
			}
			AssetDatabase.CreateAsset(material, "Assets/Materials/" + textureName + ".mat");
			Debug.Log("Created material " + textureName + " for " + go.name);
			#endif
		}
	}
开发者ID:MJ-meo-dmt,项目名称:UnitySpritesAndBones,代码行数:26,代码来源:SortLayerMaterialEditor.cs

示例3: Explode

    public override void Explode()
    {
        //try to early out if we can't draw this (not sure if this also gets us out of Unity Indie)
        if (SystemInfo.supportsImageEffects)
        {
            if ((detailThreshold > detail) || !on) return;

            if (!_delayedExplosionStarted)
            {
                _explodeDelay = explodeDelayMin + (Random.value * (explodeDelayMax - explodeDelayMin));
            }
            if (_explodeDelay <= 0)
            {
                //incoming size is based on 1, so we multiply here
                _startSize = 0f;
                _maxSize = size * 10f;

                _material = new Material(Shader.Find("HeatDistort"));
                _heatwave = GameObject.CreatePrimitive(PrimitiveType.Plane);
                Destroy(_heatwave.GetComponent(typeof(MeshCollider)));

                if (!heatwaveMaterial) heatwaveMaterial = MyDetonator().heatwaveMaterial;
                _material.CopyPropertiesFromMaterial(heatwaveMaterial);
                _heatwave.renderer.material = _material;
                _heatwave.transform.parent = this.transform;

                _delayedExplosionStarted = false;
                _explodeDelay = 0f;
            }
            else
            {
                _delayedExplosionStarted = true;
            }
        }
    }
开发者ID:CameronLonsdale,项目名称:outpost,代码行数:35,代码来源:DetonatorHeatwave.cs

示例4: Create

        public static void Create ()
        {
			if (Selection.activeGameObject != null) {
				GameObject o = Selection.activeGameObject;
				SkinnedMeshRenderer skin = o.GetComponent<SkinnedMeshRenderer>();
				SpriteRenderer spriteRenderer = o.GetComponent<SpriteRenderer>();
				if (skin == null && spriteRenderer != null) {
					Sprite thisSprite = spriteRenderer.sprite;
					SpriteMesh spriteMesh = new SpriteMesh();
					spriteMesh.spriteRenderer = spriteRenderer;
					spriteMesh.CreateSpriteMesh();
					Texture2D spriteTexture = UnityEditor.Sprites.SpriteUtility.GetSpriteTexture(spriteRenderer.sprite, false);

					// Copy the sprite material
					Material spriteMaterial = new Material(spriteRenderer.sharedMaterial);
					spriteMaterial.CopyPropertiesFromMaterial(spriteRenderer.sharedMaterial);
					spriteMaterial.mainTexture = spriteTexture;
					string sortLayerName = spriteRenderer.sortingLayerName;
					int sortOrder = spriteRenderer.sortingOrder;
					DestroyImmediate(spriteRenderer);
					Skin2D skin2D = o.AddComponent<Skin2D>();
					skin2D.sprite = thisSprite;
					skin = o.GetComponent<SkinnedMeshRenderer>();
					MeshFilter filter = o.GetComponent<MeshFilter>();
					skin.material = spriteMaterial;

					// Save out the material from the sprite so we have a default material
					if(!Directory.Exists("Assets/Materials")) {
						AssetDatabase.CreateFolder("Assets", "Materials");
						AssetDatabase.Refresh();
					}
					AssetDatabase.CreateAsset(spriteMaterial, "Assets/Materials/" + spriteMaterial.mainTexture.name + ".mat");
					Debug.Log("Created material " + spriteMaterial.mainTexture.name + " for " + skin.gameObject.name);
					skin2D.referenceMaterial = spriteMaterial;
					skin.sortingLayerName = sortLayerName;
					skin.sortingOrder = sortOrder;

					// Create the mesh from the selection
					filter.mesh = (Mesh)Selection.activeObject;
					if (filter.sharedMesh != null && skin.sharedMesh == null) {
						skin.sharedMesh = filter.sharedMesh;
					}
					// Recalculate the bone weights for the new mesh
					skin2D.RecalculateBoneWeights();
				}
				else
				{
					o = new GameObject ("Skin2D");
					Undo.RegisterCreatedObjectUndo (o, "Create Skin2D");
					o.AddComponent<Skin2D> ();
				}
			}
			else
			{
				GameObject o = new GameObject ("Skin2D");
                Undo.RegisterCreatedObjectUndo (o, "Create Skin2D");
                o.AddComponent<Skin2D> ();
			}
        }
开发者ID:OlegNovosad,项目名称:FirstPlayerEverEver,代码行数:59,代码来源:Skin2D.cs

示例5: UpdateTextures

	void UpdateTextures() {
		attackAnimationTextures = loadTextures (charName + "Attack");
		moveAnimationTextures = loadTextures (charName + "Walk");

		var clonedMaterial = new Material (Shader.Find("Standard"));
		clonedMaterial.CopyPropertiesFromMaterial (characterMaterial);
		characterMaterial = clonedMaterial;
		transform.GetChild(1).GetComponent<MeshRenderer> ().material = clonedMaterial;
		characterMaterial.SetTexture ("_MainTex", attackAnimationTextures [0]);
	}
开发者ID:vpas,项目名称:iron_lumberjack,代码行数:10,代码来源:Character.cs

示例6: OnInspectorGUI

    public override void OnInspectorGUI() {
        Skin2D skin = (Skin2D)target;

        DrawDefaultInspector();

        EditorGUILayout.Separator();

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Save as Prefab")) {
            skin.SaveAsPrefab();
        }

		EditorGUILayout.Separator();

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Recalculate Bone Weights")) {
            skin.RecalculateBoneWeights();
        }

		EditorGUILayout.Separator();

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Create Control Points")) {
            ControlPoint.CreateControlPoints(skin.GetComponent<SkinnedMeshRenderer>());
        }

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Reset Control Points")) {
            skin.ResetControlPointPositions();
        }

		EditorGUILayout.Separator();

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Generate Mesh Asset")) {
            #if UNITY_EDITOR
			// Check if the Meshes directory exists, if not, create it.
			if(!Directory.Exists("Assets/Meshes")) {
				AssetDatabase.CreateFolder("Assets", "Meshes");
				AssetDatabase.Refresh();
			}
			ScriptableObjectUtility.CreateAsset(skin.GetComponent<SkinnedMeshRenderer>().sharedMesh, "Meshes/" + skin.gameObject.name + ".Mesh");
			#endif
        }

        if (skin.GetComponent<SkinnedMeshRenderer>().sharedMaterial != null && GUILayout.Button("Generate Material Asset")) {
            #if UNITY_EDITOR
			Material material = new Material(skin.GetComponent<SkinnedMeshRenderer>().sharedMaterial);
			material.CopyPropertiesFromMaterial(skin.GetComponent<SkinnedMeshRenderer>().sharedMaterial);
			skin.GetComponent<SkinnedMeshRenderer>().sharedMaterial = material;
			if(!Directory.Exists("Assets/Materials")) {
				AssetDatabase.CreateFolder("Assets", "Materials");
				AssetDatabase.Refresh();
			}
			AssetDatabase.CreateAsset(material, "Assets/Materials/" + material.mainTexture.name + ".mat");
			Debug.Log("Created material " + material.mainTexture.name + " for " + skin.gameObject.name);
			#endif
        }
    }
开发者ID:OlegNovosad,项目名称:UnitySpritesAndBones,代码行数:54,代码来源:Skin2DEditor.cs

示例7: DelayedInit

	IEnumerator DelayedInit() {

		yield return new WaitForSeconds (0.2f) ;
		currMaterial = new Material (hairMaterial.shader);
		currMaterial.CopyPropertiesFromMaterial (hairMaterial);

		GetComponent<Anima2D.SpriteMeshInstance>().sharedMaterial = currMaterial;
		lastPosition = transform.position;
		isInitialized = true;
	
	}
开发者ID:Kundara,项目名称:project1,代码行数:11,代码来源:FlexyHair.cs

示例8: Start

	// Use this for initialization
	void Start () {
		this.charName = characterNames [Random.Range (0, characterNames.Length)];

		attackAnimationTextures = loadTextures (charName + "Attack");
		moveAnimationTextures = loadTextures (charName + "Walk");

		var clonedMaterial = new Material (Shader.Find("Standard"));
		clonedMaterial.CopyPropertiesFromMaterial (characterMaterial);
		characterMaterial = clonedMaterial;
		transform.GetChild(1).GetComponent<MeshRenderer> ().material = clonedMaterial;
		characterMaterial.SetTexture ("_MainTex", attackAnimationTextures [0]);

		characters.Add (this);
		Spawn ();
	}
开发者ID:vpas,项目名称:iron_lumberjack,代码行数:16,代码来源:Character.cs

示例9: Create

        public static void Create ()
        {
			if (Selection.activeGameObject != null) {
				GameObject o = Selection.activeGameObject;
				SkinnedMeshRenderer skin = o.GetComponent<SkinnedMeshRenderer>();
				SpriteRenderer spriteRenderer = o.GetComponent<SpriteRenderer>();
				if (skin == null && spriteRenderer != null) {
					Sprite thisSprite = spriteRenderer.sprite;
					SpriteMesh spriteMesh = new SpriteMesh();
					spriteMesh.spriteRenderer = spriteRenderer;
					spriteMesh.CreateSpriteMesh();
					Texture2D spriteTexture = UnityEditor.Sprites.SpriteUtility.GetSpriteTexture(spriteRenderer.sprite, false);
					Material spriteMaterial = new Material(spriteRenderer.sharedMaterial);
					spriteMaterial.CopyPropertiesFromMaterial(spriteRenderer.sharedMaterial);
					spriteMaterial.mainTexture = spriteTexture;
					string sortLayerName = spriteRenderer.sortingLayerName;
					int sortOrder = spriteRenderer.sortingOrder;
					DestroyImmediate(spriteRenderer);
					Skin2D skin2D = o.AddComponent<Skin2D>();
					skin2D.sprite = thisSprite;
					skin = o.GetComponent<SkinnedMeshRenderer>();
					MeshFilter filter = o.GetComponent<MeshFilter>();
					skin.material = spriteMaterial;
					skin.sortingLayerName = sortLayerName;
					skin.sortingOrder = sortOrder;
					filter.mesh = (Mesh)Selection.activeObject;
					if (filter.sharedMesh != null && skin.sharedMesh == null) {
						skin.sharedMesh = filter.sharedMesh;
					}
					// Recalculate the bone weights for the new mesh
					skin2D.RecalculateBoneWeights();
				}
				else
				{
					o = new GameObject ("Skin2D");
					Undo.RegisterCreatedObjectUndo (o, "Create Skin2D");
					o.AddComponent<Skin2D> ();
				}
			}
			else
			{
				GameObject o = new GameObject ("Skin2D");
                Undo.RegisterCreatedObjectUndo (o, "Create Skin2D");
                o.AddComponent<Skin2D> ();
			}
        }
开发者ID:OlegNovosad,项目名称:UnitySpritesAndBones,代码行数:46,代码来源:Skin2D.cs

示例10: AssignNewMaterial

        void AssignNewMaterial(GameObject grass)
        {
            currMaterial = new Material (grassMaterial.shader);
            currMaterial.CopyPropertiesFromMaterial (grassMaterial);

            Color color = new Color ( Random.Range(minColor.r , maxColor.r) ,  Random.Range(minColor.g , maxColor.g) , Random.Range(minColor.b , maxColor.b) , Random.Range(minColor.a , maxColor.a) );

            currMaterial.color = color;
            //			MeshRenderer meshRenderer = grass.GetComponent<MeshRenderer>();
            //			meshRenderer.material = currMaterial;
            //			meshRenderer.materials[0] = currMaterial;
            currMaterial.SetColor ( "_GrassColor" , color);

            Anima2D.SpriteMeshInstance spriteMI = grass.GetComponent<Anima2D.SpriteMeshInstance>();
            spriteMI.sharedMaterial = currMaterial;

            grass.GetComponent<Grass>().myMaterial = currMaterial;
        }
开发者ID:Kundara,项目名称:project1,代码行数:18,代码来源:GrassArea.cs

示例11: Awake

	public Dictionary<string, UITextureInfo> textureDetails; // texture details loaded from the TexturePacker config file

	#endregion;


	#region MonoBehaviour Functions

	virtual protected void Awake()
	{
		_meshFilter = gameObject.AddComponent<MeshFilter>();
		_meshRenderer = gameObject.AddComponent<MeshRenderer>();
		
		// Duplicate the standard material so that we're not changing the
		// supplied one - it may be used by more than one UIToolkit object
		Material duplicateMaterial = new Material (material.shader);
		duplicateMaterial.CopyPropertiesFromMaterial(material);
		material = duplicateMaterial;
		
		_meshRenderer.renderer.material = material;
		_mesh = _meshFilter.mesh;

		// Move the object to the origin so the objects drawn will not be offset from the objects they are intended to represent.
		// Offset on z axis according to the specified layer
		transform.position = new Vector3(0, 0, layer);
		transform.rotation = Quaternion.identity;
	}
开发者ID:Foxzter,项目名称:net.kibotu.sandbox.unity.dragnslay,代码行数:26,代码来源:UISpriteManager.cs

示例12: GetAssetFromBundles

 public static IEnumerator GetAssetFromBundles( string bundlePath )
 {
     EditorWww www = EditorWww.Create( bundlePath );
     while( !www.Finished ){
         yield return null;
     }
     Object asset = www.GetAsset();
     if( asset ){
         string assetPath = Path.ChangeExtension( bundlePath, Defines.AssetExt.UnityAsset );
         if( asset is Material ){
             var old = asset as Material;
             Shader shader = Shader.Find( old.shader.name );
             if( shader ){
                 var newMaterial = new Material( shader );
                 newMaterial.CopyPropertiesFromMaterial( old );
                 AssetDatabase.CreateAsset( newMaterial, assetPath );
             }
             else{
                 EditorUtility.DisplayDialog( "错误", string.Format( "Shader:{0} 不存在于本地资源", old.shader.name ), "确定" );
             }
         }
         else if( asset is ScriptableObject ){
             Object scriptableObject = ScriptableObject.CreateInstance( asset.GetType() );
             EditorUtility.CopySerialized( asset, scriptableObject );
             AssetDatabase.CreateAsset( scriptableObject, assetPath );
         }
         else if( asset is GameObject ){
             Object[] all = www.AssetBundle.LoadAllAssets();//LoadAll() change in unity5
             Debug.Log( all.Length );
             Object.Instantiate( asset );
         }
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
     }
     else{
         Debug.Log( "Error: " + bundlePath );
     }
     www.Unload();
 }
开发者ID:qingsheng1355,项目名称:test,代码行数:39,代码来源:AssetBuilder.cs

示例13: Explode

    public override void Explode()
    {
        //try to early out if we can't draw this (not sure if this also gets us out of Unity Indie)
        if (SystemInfo.supportsImageEffects)
        {
            if ((detailThreshold > detail) || !on) return;

            if (!_delayedExplosionStarted)
            {
                _explodeDelay = explodeDelayMin + (Random.value * (explodeDelayMax - explodeDelayMin));
            }
            if (_explodeDelay <= 0)
            {
                //incoming size is based on 1, so we multiply here
                _startSize = 0f;
                _maxSize = size * 10f;

                _material = new Material(Shader.Find("HeatDistort"));
                _heatwave = GameObject.CreatePrimitive(PrimitiveType.Plane);
                _heatwave.name = "Heatwave";
                _heatwave.transform.parent = this.transform;
                // billboard it so it always faces the camera - can't use regular lookat because the built in Unity plane is lame
                _heatwave.transform.rotation = Quaternion.FromToRotation(Vector3.up, Camera.main.transform.position - _heatwave.transform.position);
                Destroy(_heatwave.GetComponent(typeof(MeshCollider)));

                if (!heatwaveMaterial) heatwaveMaterial = MyDetonator().heatwaveMaterial;
                _material.CopyPropertiesFromMaterial(heatwaveMaterial);
                _heatwave.GetComponent<Renderer>().material = _material;
                _heatwave.transform.parent = this.transform;

                _delayedExplosionStarted = false;
                _explodeDelay = 0f;
            }
            else
            {
                _delayedExplosionStarted = true;
            }
        }
    }
开发者ID:MangoSister,项目名称:Doot-Doot-Cat,代码行数:39,代码来源:DetonatorHeatwave.cs

示例14: RebuildMaterial

 /// <summary>
 /// Rebuild the draw call's material.
 /// </summary>
 public void RebuildMaterial()
 {
     NGUITools.DestroyImmediate(mMat);
     mMat = new Material(mSharedMat);
     mMat.hideFlags = HideFlags.DontSave;
     mMat.CopyPropertiesFromMaterial(mSharedMat);
     mMat.renderQueue = mSharedMat.renderQueue + mRenderQueue;
 }
开发者ID:Attila22,项目名称:LittleBard,代码行数:11,代码来源:UIDrawCall.cs

示例15: Start

	void Start () {
		// Copy the skybox material to a new instance so the original skybox material is not modified and saved by accident
		skyboxInstance = new Material(skybox.shader);
		skyboxInstance.CopyPropertiesFromMaterial(skybox);
	}
开发者ID:Exosphir,项目名称:exosphir,代码行数:5,代码来源:SkyboxControl.cs


注:本文中的UnityEngine.Material.CopyPropertiesFromMaterial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。