コード例 #1
0
    void Awake()
    {
        LightShapeManager = GameObject.FindWithTag("CubeProbeManager").GetComponent("LightShapeManager") as LightShapeManager;
        if(!LightShapeAssignGame)
        {
            LightShapeAssignGame.GetComponent<LightShapeAssignGame>();
        }
        LightShapeAssignGame.hideFlags = HideFlags.HideInInspector;
        gameObject.GetComponent<LightShapeGizmo>().hideFlags = HideFlags.HideInInspector;
        gameObject.GetComponent<AltMethod>().hideFlags = HideFlags.HideInInspector;
        myCollider.hideFlags = HideFlags.HideInInspector;
        centerPos.hideFlags = HideFlags.HideInHierarchy;

        EditorApplication.playmodeStateChanged = OnEditorStateChanged;
    }
コード例 #2
0
 void OnEnable()
 {
     myTarget = (LightShapeManager) target;
     m_Object = new SerializedObject(target);
 }
コード例 #3
0
    public void RenderCubeMaps()
    {
        if(!LightShapeManager)
        {
            LightShapeManager = GameObject.FindWithTag("CubeProbeManager").GetComponent("LightShapeManager") as LightShapeManager;
        }

        rewardInt = Random.Range(0, LightShapeManager.rewardStrings.Length);

        if(!LightShapeManager.useAltMethod)
        {
            if(hasGround && renderLight)
            {
                if(!groundShape)
                {
                    groundShape = AssetDatabase.LoadAssetAtPath("Assets/LightShape/Light_Shapes/lightShape_Ground.prefab", typeof(GameObject)) as GameObject;
                }

                if(groundShape)
                {
                    groundShapeObjTemp = Instantiate(groundShape, transform.position, transform.rotation) as GameObject;
                }

                groundShapeObjTemp.transform.Translate(0, -0.1f, 0);
                groundShapeObjTemp.transform.eulerAngles = new Vector3(-90, 0, 0);
                groundShapeObjTempMesh = groundShapeObjTemp.GetComponent<MeshRenderer>();

                var gTex = groundShapeObjTempMesh.sharedMaterial.GetTexture("_MainTex") as Texture2D;
                gMat = new Material (Shader.Find("Particles/Alpha Blended"));
                gMat.SetColor("_TintColor", groundColor);
                gMat.SetTexture("_MainTex", gTex);
                groundShapeObjTempMesh.sharedMaterial = gMat;

                groundShapeObjTemp.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
            }

            if(renderLight)
            {
                if(!myLight)
                {
                    Debug.LogError("No Light Assigned. Please Assign a Light to `Use Light` to use the `Render Light` option.");
                }

                if(myLight)
                {
                    if(!lightShape)
                    {
                        lightShape = AssetDatabase.LoadAssetAtPath("Assets/LightShape/Light_Shapes/lightShape_default.prefab", typeof(GameObject)) as GameObject;
                    }

                    if(lightShape)
                    {
                   	 	lightShapeObjTemp = Instantiate(lightShape, transform.position, transform.rotation) as GameObject;
                    }

                    lightShapeMeshTemp = lightShapeObjTemp.GetComponent<MeshRenderer>();

                    var lsTex = lightShapeMeshTemp.sharedMaterial.GetTexture("_MainTex");
                    lsMat = new Material (Shader.Find("Particles/Alpha Blended"));

                    lsMat.SetTexture("_MainTex", lsTex);
                    var altZScale = 0;

                    if(renderAltLight)
                    {
                        if(!altLightShape)
                        {
                            altLightShape = AssetDatabase.LoadAssetAtPath("Assets/LightShape/Light_Shapes/lightShape_Ground.prefab", typeof(GameObject)) as GameObject;
                        }

                        if(altLightShape)
                        {
                            lightShapeObjTempAlt = Instantiate(altLightShape, transform.position, transform.rotation) as GameObject;
                        }

                        lightShapeMeshTempAlt = lightShapeObjTempAlt.GetComponent<MeshRenderer>();

                        var alsTex = lightShapeMeshTempAlt.sharedMaterial.GetTexture("_MainTex");
                        alsMat = new Material (Shader.Find("Particles/Alpha Blended"));

                        alsMat.SetTexture("_MainTex", alsTex);

                        if(overRideAltLightColor)
                        {
                            alsMat.SetColor("_TintColor", altShapeColor);
                            lightShapeMeshTempAlt.sharedMaterial = alsMat;
                        }

                        if(!overRideAltLightColor && myBackLight)
                        {
                            alsMat.SetColor("_TintColor", myBackLight.color);
                            lightShapeMeshTempAlt.sharedMaterial = alsMat;
                        }

                        if(!overRideAltLightColor && !myBackLight)
                        {
                            alsMat.SetColor("_TintColor", myLight.color * 0.5f);
                            lightShapeMeshTempAlt.sharedMaterial = alsMat;
                        }
                    }

                    if(overRideLightColor)
                    {
                        lsMat.SetColor("_TintColor", lightShapeColor);
                        lightShapeMeshTemp.sharedMaterial = lsMat;
                    }

                    if(!overRideLightColor)
                    {
                        lsMat.SetColor("_TintColor", myLight.color);
                        lightShapeMeshTemp.sharedMaterial = lsMat;
                    }

                    if(myLight.type == LightType.Directional)
                    {
                        lightShapeObjTemp.transform.rotation = myLight.gameObject.transform.rotation;
                        lightShapeObjTemp.transform.position = transform.position;
                        lightShapeObjTemp.transform.Translate(0, 0, -5);

                        if(renderAltLight && !myBackLight)
                        {
                            lightShapeObjTempAlt.transform.rotation = lightShapeObjTemp.transform.rotation;
                            lightShapeObjTempAlt.transform.Translate(0, 0, 10);
                            altZScale = -1;
                        }
                    }

                    if(myLight.type == LightType.Spot || myLight.type == LightType.Point)
                    {
                        var lightDir = Quaternion.LookRotation(transform.position - myLight.gameObject.transform.position);
                        lightShapeObjTemp.transform.rotation = lightDir;
                        lightShapeObjTemp.transform.Translate(0, 0, -5);

                        if(renderAltLight && !myBackLight)
                        {
                            lightShapeObjTempAlt.transform.rotation = lightShapeObjTemp.transform.rotation;
                            lightShapeObjTempAlt.transform.Translate(0, 0, 10);
                            altZScale = -1;
                        }
                    }

                    if(renderAltLight  && myBackLight)
                    {
                        if(myBackLight.type == LightType.Directional)
                        {
                            lightShapeObjTempAlt.transform.rotation = myBackLight.gameObject.transform.rotation;
                            lightShapeObjTempAlt.transform.Translate(0, 0, -10);
                            altZScale = 1;
                        }

                        if(myBackLight.type == LightType.Spot || myBackLight.type == LightType.Point)
                        {
                            var bLightDir = Quaternion.LookRotation(transform.position - myBackLight.gameObject.transform.position);

                            lightShapeObjTempAlt.transform.rotation = bLightDir;
                            lightShapeObjTempAlt.transform.Translate(0, 0, -10);
                            altZScale = 1;
                        }
                    }

                    lightShapeObjTemp.transform.eulerAngles = new Vector3(lightShapeObjTemp.transform.eulerAngles.x, lightShapeObjTemp.transform.eulerAngles.y, lightRot);
                    lightShapeObjTemp.transform.localScale = new Vector3(lightScaleX, lightScaleY, (lightScaleX + lightScaleY) / 2);

                    if(renderAltLight)
                    {
                        lightShapeObjTempAlt.transform.localScale = new Vector3(altLightScaleX, altLightScaleY, (altLightScaleX + altLightScaleY) * altZScale);
                        lightShapeObjTempAlt.transform.eulerAngles = new Vector3(lightShapeObjTempAlt.transform.eulerAngles.x, lightShapeObjTempAlt.transform.eulerAngles.y, altLightRot);
                    }

                    Render(lightShapeObjTemp, lightShapeObjTempAlt, groundShapeObjTemp, gMat, lsMat, alsMat);
                }
            }

            if(!renderLight)
            {
                Render(lightShapeObjTemp, lightShapeObjTempAlt, groundShapeObjTemp, gMat, lsMat, alsMat);
            }
        }

        if(LightShapeManager.useAltMethod)
        {
            Render(lightShapeObjTemp, lightShapeObjTempAlt, groundShapeObjTemp, gMat, lsMat, alsMat);
        }
    }