Hello , sorry for my English:)
This script works great in Editor,but does not workon mobile devices
Use 2D
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Line : MonoBehaviour {
public bool Dynamic;
public float Size = 1f;
public Material _mater;
[System.Serializable]
public class LineSettings{
public Vector3 StartPosition;
public Vector3 EndPosition;
public Transform StartTargetPosition;
public Transform EndTargetPosition;
public LineRenderer LR;
} public List<LineSettings> lineSettings;
public Color colorLineStart = Color.blue;
public Color colorLineEnd = Color.green;
public LayerMask Layer;
public int OrderInLayer;
private Transform _thisTransform;
void Awake(){
_thisTransform = transform;
}
void Update(){
if (Dynamic ) {
if ( lineSettings != null ){
for ( int i = 0; i < lineSettings.Count; i++){
lineSettings[i].LR.SetPosition(0,lineSettings[i].StartTargetPosition.position);
lineSettings[i].LR.SetPosition(1,lineSettings[i].EndTargetPosition.position);
}
}
}
}
public void AddLine(Transform _start,Transform _end){
LineSettings NL = new LineSettings();
GameObject NewLine = new GameObject("MyLine",typeof(LineRenderer));
NewLine.transform.SetParent(_thisTransform);
NewLine.layer = 11;
NL.StartPosition = _start.position;
NL.EndPosition = _end.position;
NL.StartTargetPosition = _start;
NL.EndTargetPosition = _end;
NL.LR = NewLine.GetComponent<LineRenderer>();
NL.LR.sortingLayerName = "Girl";
NL.LR.sortingOrder = OrderInLayer;
NL.LR.material = _mater;
NL.LR.SetColors(colorLineStart,colorLineEnd);
NL.LR.useLightProbes = false;
NL.LR.receiveShadows = false;
NL.LR.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
NL.LR.SetWidth(Size,Size);
NL.LR.SetVertexCount(2);
if (!Dynamic){
NL.LR.SetPosition(0, NL.StartPosition);
NL.LR.SetPosition(1, NL.EndPosition);
}
lineSettings.Add(NL);
}
public void DeleteLine(int number){
Destroy(_thisTransform.GetChild(number).gameObject);
lineSettings.RemoveAt(number);
}
public void ClearLine(){
for ( int i = 0; i< _thisTransform.childCount; i ++ ) {
Destroy(_thisTransform.GetChild(i).gameObject);
}
lineSettings.Clear();
}
// lineSettings[i].LR.SetPosition(0,new Vector3(lineSettings[i].StartTargetPosition.position.x,lineSettings[i].StartTargetPosition.position.y,0));
// lineSettings[i].LR.SetPosition(1,new Vector3(lineSettings[i].EndTargetPosition.position.x,lineSettings[i].EndTargetPosition.position.y,0));
}
Don’t have any guesses why
My actions to correct the problem:
1.Change the z coordinate of -100 to 100
2.Tried to use different shaders
3. in the Edit menu/Graphics Add shaders to"Always included shaders"
Nothing helps, works in the editor,but not on the device,help please
Thanks for the help