Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.82 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System;
  5.  
  6. public class ImageCreation : MonoBehaviour
  7. {
  8.     public GameObject Parentsplane = GameObject.CreatePrimitive (PrimitiveType.Plane); //Parent Plane
  9.     public List<GameObject> gameList = new List<GameObject>();
  10.     WWW www;
  11.  
  12.     public float screenHeight,screenWidth,screenOffsetY,screenOffsetX,scalingFactorX,scalingFactorY;
  13.  
  14.     public string pathPrefix = @"file://";
  15.     public string pathImageAssets = @"/storage/sdcard1";
  16.     public string pathSmall = @"/Android/pics";
  17.     public string filename = @"/";
  18.     public string fileSuffix = @".jpg";
  19.     public string indexSuffix = @"001";
  20.     public bool isWidgetTouched=false;
  21.  
  22.     //float screenHeight,screenWidth,screenOffsetY,screenOffsetX,scalingFactorX,scalingFactorY;
  23.     bool isTouched;
  24.     public GameObject touchedObject;      
  25.     AnimationClip animationClip;
  26.     AnimationCurve curve ;
  27.     private bool touchStarted = false,isWidgetOpen=false;
  28.     private Vector3 touchOffset;
  29.     float widgetUpperBound,widgetLowerBound;
  30.     Vector3 touchPosition,prevTouchPosition = new Vector3(0,0,0),firstTouchPos;
  31.     float activeStateOpacity;
  32.     public float widgetEnd;
  33.     public float widgetStart;
  34.     private Vector2 fp = new Vector2();  // first finger position
  35.     private Vector2 lp = new Vector2();  // last finger position
  36.  
  37.     // Use this for initialization
  38.     IEnumerator Start ()
  39.     {
  40.         Camera.main.orthographic = true;
  41.  
  42.         //Calculating the screen height and screen width and also offset from them
  43.         Vector3 tempPos;
  44.         tempPos = Camera.main.ScreenToWorldPoint (new Vector3(Screen.width,Screen.height,0));
  45.         screenHeight=2*tempPos.y;
  46.         screenWidth= 2*tempPos.x;    
  47.         screenOffsetY=tempPos.y;
  48.         screenOffsetX= tempPos.x;
  49.  
  50.         float[] XPosVector3 = new float[100];
  51.         float[] YPosVector3 = new float[100];
  52.         float[] ZPosVector3 = new float[100];
  53.        
  54.         XPosVector3[0]=-1.71f;
  55.         YPosVector3[0]=0f;
  56.         ZPosVector3[0]=0f;
  57.         //Positioning the planes
  58.         int num_image = 5;
  59.         for (int j=0; j<num_image; j++)
  60.         {
  61.             XPosVector3[j+1]=XPosVector3[j]+3.3f;
  62.             YPosVector3[j]=0f;
  63.             ZPosVector3[j]=0f;
  64.         }
  65.         //Creation of parent plane
  66.  
  67.         Parentsplane.name="parentplane";
  68.         Parentsplane.AddComponent<Animation> ();
  69.         Parentsplane.AddComponent<BoxCollider> ();
  70.         Parentsplane.AddComponent ("drag");
  71.  
  72.         animationClip = new AnimationClip ();
  73.         //Laying the images over the plane
  74.         Parentsplane.transform.position = new Vector3 (0, 0, 0);
  75.         Parentsplane.transform.localScale = new Vector3 (2.5f, 1, 0.3f);
  76.  
  77.  
  78.  
  79.             int i = 0;
  80.            
  81.             indexSuffix = "000";
  82.             //Creation of plane obj, renaming it and assing parent and positioning them
  83.             GameObject planeObj = GameObject.CreatePrimitive (PrimitiveType.Plane);
  84.             planeObj.name = "plane0";
  85.  
  86.             planeObj.transform.position = new Vector3(XPosVector3[0],YPosVector3[0],ZPosVector3[0]);
  87.             planeObj.transform.eulerAngles = new Vector3 (0,180f, 0f);
  88.             planeObj.transform.localScale = new Vector3 (0.3f, 0, 0.3f);
  89.             planeObj.transform.parent = Parentsplane.transform;//Creation of parent plane to hold the rest of the planes
  90.  
  91.             string fullFilename =   pathPrefix + pathImageAssets + pathSmall + filename + indexSuffix + fileSuffix;
  92.             Debug.Log("Fullfimename is " + fullFilename);
  93.             Debug.Log ("App path is " + Application.dataPath);
  94.             www = new WWW (fullFilename);
  95.             fullFilename="";
  96.             yield return www;
  97.            
  98.             Debug.Log ("No of bytes downloaded are " + www.bytesDownloaded);
  99.             Debug.Log ("text content of pic is " + www.text);
  100.  
  101.             planeObj.renderer.material.mainTexture = www.texture;
  102.  
  103.             //Add Box Colider for planeeveryobject
  104.             planeObj.AddComponent<BoxCollider>();
  105.             planeObj.AddComponent ("drag");
  106.  
  107.  
  108.         Destroy(Parentsplane.GetComponent<MeshRenderer> ());
  109.         Parentsplane.transform.eulerAngles = new Vector3(270f, 0, 0f);
  110.  
  111.     }
  112.     // Update is called once per frame
  113.     void Update ()
  114.     {  
  115.  
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement