コード例 #1
0
        public static SurfaceComponent CreateEmpty(ModelComponentType componentType)
        {
            switch (componentType)
            {
            case ModelComponentType.Part:
                return(new PartModel());

            case ModelComponentType.MaleStud:
                return(new MaleStudModel());

            case ModelComponentType.FemaleStud:
                return(new FemaleStudModel());

            case ModelComponentType.BrickTube:
                return(new BrickTubeModel());
            }
            return(null);
        }
コード例 #2
0
ファイル: ModelSetup.cs プロジェクト: 3DArcade/3DArcade
        private void SetupVideo(GameObject child, List <Texture2D> textureList, string url, ModelComponentType modelComponentType, ModelSharedProperties modelSharedProperties)
        {
            var modelVideoSetup = child.GetComponent <ModelVideoSetup>();

            if (modelVideoSetup == null)
            {
                modelVideoSetup = child.AddComponent <ModelVideoSetup>();
            }
            var video  = child.GetComponent <UnityEngine.Video.VideoPlayer>();
            var taudio = child.GetComponent <UnityEngine.AudioSource>();

            if (taudio == null && modelSharedProperties.spatialSound == true)
            {
                if (url != null)
                {
                    taudio              = child.AddComponent <UnityEngine.AudioSource>();
                    taudio.playOnAwake  = false;
                    taudio.spatialBlend = 1;
                    taudio.spatialize   = true;
                    taudio.minDistance  = 1;
                    taudio.maxDistance  = 20;
                    taudio.enabled      = false;
                }
            }
            if (video == null)
            {
                if (url != null)
                {
                    video = child.AddComponent <UnityEngine.Video.VideoPlayer>();
                }
            }
            else
            {
                if (url == null)
                {
                    if (Application.isPlaying)
                    {
                        Destroy(video);
                    }
                    else
                    {
                        DestroyImmediate(video);
                    }
                }
            }
            if (video != null)
            {
                video.Pause();
                if (modelSharedProperties.spatialSound)
                {
                    video.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.AudioSource;
                    video.SetTargetAudioSource(0, taudio);
                }
                video.enabled = false;
            }
            if (modelVideoSetup != null)
            {
                modelVideoSetup.Setup(textureList, url, animatedTextureSpeed, modelComponentType, GetModelProperties(), modelSharedProperties);
            }
        }
コード例 #3
0
ファイル: InstructionEditView.cs プロジェクト: kiquenet/B4F
 public RebalanceExclusionDetails(int componentKey, string componentName, ModelComponentType componentType)
 {
     this.ComponentKey = componentKey;
     this.ComponentName = componentName;
     this.ComponentType = componentType;
     Key = (ComponentType == ModelComponentType.Instrument ? "I" : "M") + ComponentKey.ToString();
 }
コード例 #4
0
ファイル: ModelImageSetup.cs プロジェクト: 3DArcade/3DArcade
        public void Setup(Texture2D tex, RenderSettings renderSettings, ModelProperties modelProperties, ModelComponentType modelComponentType)
        {
            if (!Application.isPlaying)
            {
                return;
            }
            Renderer thisRenderer = GetComponent <Renderer>();

            if (thisRenderer == null || modelProperties == null)
            {
                return;
            }

            // Generate a Marquee texture when there is none available.
            if (tex == null && transform.parent.CompareTag("gamemodel") && (modelComponentType == ModelComponentType.Marquee))
            {
                GameObject obj = GameObject.Find("RenderCanvasToTexture");
                if (obj != null)
                {
                    RenderCanvasToTexture renderCanvasToTexture = obj.GetComponent <RenderCanvasToTexture>();
                    if (renderCanvasToTexture != null)
                    {
                        tex = renderCanvasToTexture.RenderToTexture((thisRenderer.bounds.size.y / thisRenderer.bounds.size.x), modelProperties);
                    }
                }
            }

            // Create a new material from the currentr material, so we have an unique one.
            var tempMaterial = new Material(thisRenderer.sharedMaterial);
            var shaderName   = tempMaterial.shader.name;
            var newShader    = Shader.Find(shaderName);

            // TODO: This fixes black textures when some prefabs are loaded from an assetbundle, still nescessary?
            if (newShader != null)
            {
                tempMaterial.shader = newShader;
            }
            else
            {
                Debug.LogWarning("unable to refresh shader: " + shaderName + " in material " + tempMaterial.name);
            }

            tempMaterial.mainTexture = tex != null ? tex : thisRenderer.material.mainTexture;

            // Also put it on the emissive map.
            if (modelComponentType == ModelComponentType.Marquee)
            {
                Texture myTexture = tempMaterial.GetTexture("_MainTex");
                tempMaterial.SetTexture("_EmissionMap", myTexture);
                tempMaterial.color = Color.black;
                tempMaterial.SetColor("_EmissionColor", Color.white);
                tempMaterial.SetVector("_EmissionColor", Color.white * renderSettings.marqueeIntensity);
                tempMaterial.EnableKeyword("_EMISSION");
                tempMaterial.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
            }

            // Put the new texture on all the model components that use this material, for magic pixels!
            if (tex != null && modelComponentType != ModelComponentType.Screen)
            {
                var r = transform.parent.GetComponentsInChildren(typeof(Renderer));
                foreach (Renderer i in r)
                {
                    if (thisRenderer.sharedMaterial.mainTexture == null || i.sharedMaterial.mainTexture == null)
                    {
                        continue;
                    }
                    int id1 = thisRenderer.sharedMaterial.mainTexture.GetInstanceID();
                    int id2 = i.sharedMaterial.mainTexture.GetInstanceID();
                    if (id1 == id2)
                    {
                        if (i.transform.gameObject.name != transform.gameObject.name)
                        {
                            var  tempMaterial2 = new Material(i.material);
                            bool isEmissive    = i.material.IsKeywordEnabled("_Emission");
                            i.material             = tempMaterial2;
                            i.material.mainTexture = tempMaterial.mainTexture;
                            if (isEmissive)
                            {
                                Texture myTexture = tempMaterial.GetTexture("_MainTex");
                                i.material.SetTexture("_EmissionMap", myTexture);
                            }
                        }
                    }
                }
            }
            thisRenderer.material = tempMaterial;
            savedMaterial         = tempMaterial;
        }
コード例 #5
0
 /// <summary>
 /// Informs the developer if a particular model component type will include the hash of the parent.
 /// </summary>
 /// <param name="type">True if the component includes parent hash.</param>
 /// <since>6.0</since>
 public static bool ModelComponentTypeIncludesParent(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_UniqueNameIncludesParent(type));
 }
コード例 #6
0
 /// <summary>
 /// Informs the developer if a particular model component type will require case-ignoring searching within a document.
 /// This is currently true with groups; false otherwise.
 /// </summary>
 /// <param name="type">True if the component ignores case.</param>
 /// <since>6.0</since>
 public static bool ModelComponentTypeIgnoresCase(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_UniqueNameIgnoresCase(type));
 }
コード例 #7
0
 /// <summary>
 /// Informs the developer if a particular model component type will require uniqueness within a document.
 /// This is currently true with render materials and model geometry; false otherwise.
 /// </summary>
 /// <param name="type">The type to check.</param>
 /// <returns>true with render materials and model geometry; false otherwise.</returns>
 /// <since>6.0</since>
 public static bool ModelComponentTypeRequiresUniqueName(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_RequiresUniqueName(type));
 }
コード例 #8
0
ファイル: ModelMaintenance.aspx.cs プロジェクト: kiquenet/B4F
 private int checkIndexOfEntry(ModelComponentType modelComponentType, int componentID)
 {
     int returnValue = -1;
     for (int i = 0; i < this.NewModelVersion.Count; i++)
     {
         ModelComponentHelper dr = this.NewModelVersion[i];
         if ((dr.ModelComponentType == modelComponentType) && (dr.ComponentID == componentID))
         {
             returnValue = i;
         }
     }
     return returnValue;
 }
コード例 #9
0
ファイル: ModelVideoSetup.cs プロジェクト: 3DArcade/3DArcade
        public void Setup(List <Texture2D> textureList, string videoURL, float?animatedTextureSpeed, ModelComponentType modelComponentType, ModelProperties modelProperties, ModelSharedProperties modelSharedProperties)
        {
            //Debug.Log("videosetup " + gameObject.transform.parent.name + " imagecount " + textureList.Count + " " + videoURL + " " + (videoPlayer == null));

            this.modelProperties       = modelProperties;
            this.modelComponentType    = modelComponentType;
            this.imageList             = null;
            this.modelSharedProperties = modelSharedProperties;
            this.dummyNode             = gameObject.transform.parent.transform.parent.gameObject;

            string layer = LayerMask.LayerToName(gameObject.layer);

            if (layer.StartsWith("Arcade"))
            {
                layerMask   = LayerMask.GetMask("Arcade/ArcadeModels", "Arcade/GameModels", "Arcade/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.FpsArcade];
                arcadeLayer = true;
            }
            else
            {
                layerMask   = LayerMask.GetMask("Menu/ArcadeModels", "Menu/GameModels", "Menu/PropModels");
                thisCamera  = ArcadeManager.arcadeCameras[ArcadeType.CylMenu];
                arcadeLayer = false;
            }

            if (ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsArcade.ToString() || ArcadeManager.arcadeConfiguration.arcadeType == ArcadeType.FpsMenu.ToString())
            {
                isCylArcade = false;
                maxDistance = 5f;
            }
            else
            {
                isCylArcade = true;
                maxDistance = 10000f;
            }

            // Setup image, nescessary for magic pixels and to get an unique material instance.
            Texture2D tex = null;

            if (textureList.Count > 0)
            {
                tex = textureList[0];
            }
            ModelImageSetup modelImageSetup = GetComponent <ModelImageSetup>();

            if (modelImageSetup == null)
            {
                modelImageSetup = gameObject.AddComponent <ModelImageSetup>();
            }
            modelImageSetup.Setup(tex, modelSharedProperties.renderSettings, modelProperties, modelComponentType);

            if (videoURL != null && videoPlayer == null)
            {
                videoPlayer = gameObject.GetComponent <UnityEngine.Video.VideoPlayer>();
            }
            if (animatedTextureSpeed != null)
            {
                waitTime = animatedTextureSpeed.Value;
            }
            videoEnabled = (ModelVideoEnabled)System.Enum.Parse(typeof(ModelVideoEnabled), modelSharedProperties.videoOnModelEnabled);
            if (videoURL == null)
            {
                videoEnabled = ModelVideoEnabled.Never;
            }
            else
            {
                if (videoPlayer != null && videoEnabled != ModelVideoEnabled.Never)
                {
                    videoPlayer.SetDirectAudioMute(0, true);
                    videoPlayer.enabled = true;
                    videoPlayer.url     = videoURL;
                }
            }
            if (textureList.Count > 0)
            {
                imageList = textureList;
                if (renderer != null)
                {
                    renderer.material.mainTexture = textureList[0];
                }
            }
            else
            {
                if (renderer != null && transform.parent.CompareTag("gamemodel") && modelComponentType == ModelComponentType.Screen)
                {
                    renderer.material.mainTexture = Texture2D.blackTexture;
                }
            }
            if (renderer != null && (textureList.Count > 0 || videoEnabled != ModelVideoEnabled.Never))
            {
                SetupVideoPlayer();
            }
        }