コード例 #1
0
        public void Edit(ProceduralObject obj, Vector2 position)
        {
            editingObject       = obj;
            scrollParams        = Vector2.zero;
            scrollTex           = Vector2.zero;
            movingField         = -1;
            dragTexPos          = Vector2.zero;
            windowRect.position = position;
            Texture tex = ProceduralUtils.GetOriginalTexture(obj);

            originalTex = new Texture2D(tex.width, tex.height, TextureFormat.RGBA32, false);
            originalTex.SetPixels(((Texture2D)tex).GetPixels());
            windowTex = (Texture2D)GameObject.Instantiate(originalTex);
            // load stored data if it exists
            if (editingObject.m_textParameters == null)
            {
                parameters    = new TextParameters();
                parametersOld = new TextParameters();
            }
            else
            {
                parameters    = editingObject.m_textParameters;
                parametersOld = TextParameters.Clone(editingObject.m_textParameters, false);
                windowTex     = parameters.ApplyParameters(originalTex);
                editingObject.m_material.mainTexture = windowTex as Texture;
            }
            updateTimer = 0f;
            dragTimer   = 0f;
            zoomFactor  = 1f;
            if (!showWindow)
            {
                showWindow = true;
            }
        }
コード例 #2
0
 public void Apply()
 {
     foreach (var obj in selection)
     {
         obj.customTexture = tex;
         var texture = (tex == null) ? ProceduralUtils.GetBasePrefabMainTex(obj) : tex;
         obj.m_material.mainTexture = texture;
         if (obj.m_textParameters != null)
         {
             if (obj.m_textParameters.Count() > 0)
             {
                 Texture original    = ProceduralUtils.GetOriginalTexture(obj);
                 var     originalTex = new Texture2D(original.width, original.height, TextureFormat.RGBA32, false);
                 originalTex.SetPixels(((Texture2D)original).GetPixels());
                 var newtex = (Texture2D)GameObject.Instantiate(originalTex);
                 obj.m_material.mainTexture = obj.m_textParameters.ApplyParameters(originalTex) as Texture;
             }
         }
     }
 }