У меня пока никак не выходит поменять меш.
быстро набросал - всё работает.
Список разделов › Геймдев в Blender › Unity 3D
Flogger-K писал(а):что такое префаб
Flogger-K писал(а):Вот так, значит. Во всем виноват оказался fbx. Блин.
Flogger-K писал(а):child.gameObject.GetComponent<Renderer>().material = materialUnit[0];
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartAircraft : MonoBehaviour {
public Material[] materialUnit = new Material[4];
public Mesh[] meshFus = new Mesh[6];
public Mesh[] meshCnp = new Mesh[2];
public Mesh[] meshStworki = new Mesh[2];
public Mesh[] meshGlass = new Mesh[2];
public Mesh[] meshCnpGlass = new Mesh[2];
public Transform[] childObj = new Transform[18];
public MeshFilter meshFusFilter;
public MeshFilter meshGlassFilter;
public MeshFilter meshCnpGlassFilter;
public MeshFilter meshStworkiFilter;
public MeshFilter meshCnpFilter;
public int typeAircraft = 0;
// Use this for initialization
void Start () {
}
//ВСЕ МАНИПУЛЯЦИИ будут производиться ОДИН раз - при старте игры. Максимум - еще раз - при получении повреждений
// Update is called once per frame
void Update () {
if( Input.GetKeyDown( KeyCode.Z ) )
{
typeAircraft+= 1;
}
if( typeAircraft == 5 )
{
typeAircraft = 0;
}
// MiG-23BN
if( typeAircraft == 0 )
{
meshFusFilter.mesh = meshFus[0];
meshGlassFilter.mesh = meshGlass[1];
meshCnpGlassFilter.mesh = meshCnpGlass[1];
meshCnpFilter.mesh = meshCnp[1];
meshStworkiFilter.mesh = meshGlass[1];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[0];
}
}
// MiG-23MF
if( typeAircraft == 1 )
{
meshFusFilter.mesh = meshFus[1];
meshGlassFilter.mesh = meshGlass[0];
meshCnpGlassFilter.mesh = meshCnpGlass[0];
meshCnpFilter.mesh = meshCnp[0];
meshStworkiFilter.mesh = meshGlass[0];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[1];
}
}
// MiG-23ML
if( typeAircraft == 2 )
{
meshFusFilter.mesh = meshFus[2];
meshGlassFilter.mesh = meshGlass[0];
meshCnpGlassFilter.mesh = meshCnpGlass[0];
meshCnpFilter.mesh = meshCnp[0];
meshStworkiFilter.mesh = meshGlass[0];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[2];
}
}
// MiG-27K
if( typeAircraft == 3 )
{
meshFusFilter.mesh = meshFus[5];
meshGlassFilter.mesh = meshGlass[1];
meshCnpGlassFilter.mesh = meshCnpGlass[1];
meshCnpFilter.mesh = meshCnp[1];
meshStworkiFilter.mesh = meshGlass[1];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[3];
}
}
}
}
Flogger-K писал(а):void Update () {
if( Input.GetKeyDown( KeyCode.Z ) )
{
typeAircraft+= 1;
}
if( typeAircraft == 5 )
{
typeAircraft = 0;
}
// MiG-23BN
if( typeAircraft == 0 )
{
meshFusFilter.mesh = meshFus[0];
meshGlassFilter.mesh = meshGlass[1];
meshCnpGlassFilter.mesh = meshCnpGlass[1];
meshCnpFilter.mesh = meshCnp[1];
meshStworkiFilter.mesh = meshGlass[1];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[0];
}
}
void MyMethod(int masalyot_number)
{
typeAircraft = masalyot_number;
if( typeAircraft == 0)
{
meshFusFilter.mesh = meshFus[0];
meshGlassFilter.mesh = meshGlass[1];
meshCnpGlassFilter.mesh = meshCnpGlass[1];
meshCnpFilter.mesh = meshCnp[1];
meshStworkiFilter.mesh = meshGlass[1];
foreach( Transform child in childObj )
{
child.gameObject.GetComponent<MeshRenderer>().material = materialUnit[0];
}
}
}
void Update () {
if( Input.GetKeyDown( KeyCode.Z ) )
MyMethod(1);
//ВСЕ МАНИПУЛЯЦИИ будут производиться ОДИН раз - при старте игры. Максимум - еще раз - при получении повреждений
// Update is called once per frame
void Update ()
Flogger-K писал(а):кмментарий перед Update в скрипте
Да, декали. Там вроде был готовый шейдер.Flogger-K писал(а):Можно опять же сделать с мутацией меша и материалов, но есть ли еще какие-то способы? Куда копать? Декали?
Flogger-K писал(а):P.S. Как обнаружилось, многомерные массивы в инспекторе не отображаются. поэтому объявление типа public Mesh[ , ] meshMutate = new Mesh[4,2]; ничего не дало. Как добиться появления многомерных массивов в инспекторе?
[System.Serializable]
public class My_Class
{
public GameObject[] obj;
}
Сейчас этот раздел просматривают: 2 гостя