Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- public class ImageCreation : MonoBehaviour
- {
- public GameObject Parentsplane = GameObject.CreatePrimitive (PrimitiveType.Plane); //Parent Plane
- public List<GameObject> gameList = new List<GameObject>();
- WWW www;
- public float screenHeight,screenWidth,screenOffsetY,screenOffsetX,scalingFactorX,scalingFactorY;
- public string pathPrefix = @"file://";
- public string pathImageAssets = @"/storage/sdcard1";
- public string pathSmall = @"/Android/pics";
- public string filename = @"/";
- public string fileSuffix = @".jpg";
- public string indexSuffix = @"001";
- public bool isWidgetTouched=false;
- //float screenHeight,screenWidth,screenOffsetY,screenOffsetX,scalingFactorX,scalingFactorY;
- bool isTouched;
- public GameObject touchedObject;
- AnimationClip animationClip;
- AnimationCurve curve ;
- private bool touchStarted = false,isWidgetOpen=false;
- private Vector3 touchOffset;
- float widgetUpperBound,widgetLowerBound;
- Vector3 touchPosition,prevTouchPosition = new Vector3(0,0,0),firstTouchPos;
- float activeStateOpacity;
- public float widgetEnd;
- public float widgetStart;
- private Vector2 fp = new Vector2(); // first finger position
- private Vector2 lp = new Vector2(); // last finger position
- // Use this for initialization
- IEnumerator Start ()
- {
- Camera.main.orthographic = true;
- //Calculating the screen height and screen width and also offset from them
- Vector3 tempPos;
- tempPos = Camera.main.ScreenToWorldPoint (new Vector3(Screen.width,Screen.height,0));
- screenHeight=2*tempPos.y;
- screenWidth= 2*tempPos.x;
- screenOffsetY=tempPos.y;
- screenOffsetX= tempPos.x;
- float[] XPosVector3 = new float[100];
- float[] YPosVector3 = new float[100];
- float[] ZPosVector3 = new float[100];
- XPosVector3[0]=-1.71f;
- YPosVector3[0]=0f;
- ZPosVector3[0]=0f;
- //Positioning the planes
- int num_image = 5;
- for (int j=0; j<num_image; j++)
- {
- XPosVector3[j+1]=XPosVector3[j]+3.3f;
- YPosVector3[j]=0f;
- ZPosVector3[j]=0f;
- }
- //Creation of parent plane
- Parentsplane.name="parentplane";
- Parentsplane.AddComponent<Animation> ();
- Parentsplane.AddComponent<BoxCollider> ();
- Parentsplane.AddComponent ("drag");
- animationClip = new AnimationClip ();
- //Laying the images over the plane
- Parentsplane.transform.position = new Vector3 (0, 0, 0);
- Parentsplane.transform.localScale = new Vector3 (2.5f, 1, 0.3f);
- int i = 0;
- indexSuffix = "000";
- //Creation of plane obj, renaming it and assing parent and positioning them
- GameObject planeObj = GameObject.CreatePrimitive (PrimitiveType.Plane);
- planeObj.name = "plane0";
- planeObj.transform.position = new Vector3(XPosVector3[0],YPosVector3[0],ZPosVector3[0]);
- planeObj.transform.eulerAngles = new Vector3 (0,180f, 0f);
- planeObj.transform.localScale = new Vector3 (0.3f, 0, 0.3f);
- planeObj.transform.parent = Parentsplane.transform;//Creation of parent plane to hold the rest of the planes
- string fullFilename = pathPrefix + pathImageAssets + pathSmall + filename + indexSuffix + fileSuffix;
- Debug.Log("Fullfimename is " + fullFilename);
- Debug.Log ("App path is " + Application.dataPath);
- www = new WWW (fullFilename);
- fullFilename="";
- yield return www;
- Debug.Log ("No of bytes downloaded are " + www.bytesDownloaded);
- Debug.Log ("text content of pic is " + www.text);
- planeObj.renderer.material.mainTexture = www.texture;
- //Add Box Colider for planeeveryobject
- planeObj.AddComponent<BoxCollider>();
- planeObj.AddComponent ("drag");
- Destroy(Parentsplane.GetComponent<MeshRenderer> ());
- Parentsplane.transform.eulerAngles = new Vector3(270f, 0, 0f);
- }
- // Update is called once per frame
- void Update ()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement