Пример #1
0
        static void addSpotCar()
        {
            reloadAsset();

            //main spot

            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardSpotCarType1.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DSpotCar");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
            s.setMainMaterial(m);
            s.Rebuild();
            s.Segments           = 5;
            s.RangeAngle         = 107;
            s.SolidColor         = true;
            s.LightColor         = new Color(229 / 255f, 1f, 171 / 255f);
            s.uv_Offset          = new Vector2(.5f, 0f);
            s.uv_Scale           = new Vector2(1.25f, 1f);
            s.debugLines         = false;
            s.recalculateNormals = false;
            s.SortOrderID        = -1;

            //Slave spot
            //m = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardSpotCarType1.mat", typeof(Material)) as Material;
            GameObject gameObject2 = new GameObject("2DSpotCarBright");

            gameObject2.transform.parent = gameObject.transform;
            s             = gameObject2.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
            s.setMainMaterial(m);
            s.Rebuild();
            s.Segments           = 5;
            s.RangeAngle         = 180;
            s.LightRadius        = 20;
            s.SolidColor         = true;
            s.LightColor         = new Color(229 / 255f, 1f, 171 / 255f);
            s.uv_Offset          = new Vector2(.5f, 0f);
            s.uv_Scale           = new Vector2(.54f, 2.9f);
            s.debugLines         = false;
            s.recalculateNormals = false;
            s.SortOrderID        = -1;
        }
Пример #2
0
    static void addGradient()
    {
        reloadAsset();
        Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Materials/StandardLightMaterialGradient.mat", typeof(Material)) as Material;
        GameObject gameObject = new GameObject("2DLight");

        DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
        s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
        s.setMainMaterial(m);
        s.Rebuild();
    }
Пример #3
0
    static void addTexturized()
    {
        reloadAsset();
        Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightTexturizedMaterial.mat", typeof(Material)) as Material;
        GameObject gameObject = new GameObject("2DLight");

        DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
        s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        s.SolidColor  = true;
        s.LightColor  = Color.red;
        s.setMainMaterial(m);
        s.Version = AssetUtility.LoadProperty("version", tmpAsset);
        s.Rebuild();
    }
Пример #4
0
        static void addSpot()
        {
            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightMaterialGradient.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DLight");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
            s.setMainMaterial(m);
            s.Rebuild();
            s.Segments    = 9;
            s.RangeAngle  = 90;
            s.SortOrderID = -1;
        }
Пример #5
0
        static void addTexturized2()
        {
            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightTexturizedMaterialBlend.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DDLight");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.SolidColor  = true;
            s.LightColor  = Color.red;
            s.uv_Scale    = new Vector3(.38f, .38f);
            s.SortOrderID = -1;
            s.setMainMaterial(m);
            s.Version = AssetUtility.LoadProperty("version", tmpAsset);
            s.Rebuild();
        }
Пример #6
0
        static void addOccluder()
        {
            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardOccluderMaterial.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DDLight");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.SolidColor  = true;
            s.LightColor  = new Color(59 / 255f, 122 / 255f, 59 / 255f);
            s.uv_Scale    = new Vector3(.38f, .38f);
            s.SortOrderID = -1;
            s.setMainMaterial(m);
            //s.strokeRender = .35f;
            s.Segments = 30;
            //s.intelliderConvex = false;
            s.Version = AssetUtility.LoadProperty("version", tmpAsset);
            s.Rebuild();
        }
Пример #7
0
        static void addSight()
        {
            //EditorUtility.DisplayDialog("NOTES","1. Events require 'Game' window and at least one 'Camera' to get working (runtime or/and editor). ", "OK");



            // adding sight object

            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightMaterialGradient.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DSight");

            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
            s.setMainMaterial(m);
            s.Rebuild();
            s.Segments    = 5;
            s.RangeAngle  = 80;
            s.SortOrderID = -1;

            //Enable events
            s.useEvents          = true;
            s.objectsWithinSight = true;



            //adding listener
            Object     prefab = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Casters/box.prefab", typeof(GameObject));
            GameObject go     = Instantiate(prefab, new Vector3(0, 7f, 0), Quaternion.Euler(new Vector3(0, 0, 0.0001f))) as GameObject;

            go.name = "2DSight_Listener";
            go.AddComponent <SightListenerTemplate> ();
            go.layer = AssetUtility.LoadPropertyAsInt("layerCaster", tmpAsset);
            //SightListenerTemplate listener = go.GetComponent<SightListenerTemplate> ();

            s.addingPersistentUnityEvents(go);

            //EditorUtility.SetDirty (s);
        }